This module provides a TCP server that multiplexes incoming and outgoing messages from many connected peers onto a single pair of input and output channels. The socket address of the peer is used to identify the source and destination of messages.
This interface introduces a new error condition: that a message on the outgoing channel has a socket address for which no socket exists. This may occur because of incorrect usage of this library, or because a peer disconnected after the client placed a message on the outgoing channel, but before that message was sent. Currently, the server does not notify its caller of the occurrence of this error.
- muxedTCPServer :: ServerPortNumber -> IO (IO (TCPMessage (TransactionID, SCMessage)), SockAddr -> (TransactionID, CSMessage) -> IO ())
- data TCPMessage a
- type ServerPortNumber = Word16
Documentation
muxedTCPServer :: ServerPortNumber -> IO (IO (TCPMessage (TransactionID, SCMessage)), SockAddr -> (TransactionID, CSMessage) -> IO ())Source
Runs a server that returns two commands, one to receive the next message from any connected client, and one that sends a message to a client.
data TCPMessage a Source
The type of externally visible events that may occur for the multiplexed TCP server.
ConnectionEstablished SockAddr | A connection to a peer with the given address is established. |
ConnectionTerminated SockAddr | A connection with the given address is terminated, due to the given exception. |
PeerMessage SockAddr a | A message of type |
Functor TCPMessage | |
Eq a => Eq (TCPMessage a) | |
Show a => Show (TCPMessage a) |
type ServerPortNumber = Word16Source