Safe Haskell | None |
---|
Underlying transport abstraction
- class Transport t where
- runSession :: t -> TransportM a -> IO a
- closeConnection :: t -> IO ()
- class Transport (ServerTransport s) => Server s where
- type ServerTransport s
- runServer :: s -> (ServerTransport s -> IO ()) -> IO ()
- cleanup :: s -> IO ()
- type TransportM = ReaderT SendPacketFn (ConduitM Packet Void IO)
- type SendPacketFn = Packet -> IO ()
- sendt :: Term -> TransportM ()
- recvt :: TransportM (Maybe Term)
- recvtForever :: (Term -> TransportM a) -> TransportM ()
- data TCP = TCP {
- getTcpSocket :: !Socket
- tcpClient :: HostName -> PortNumber -> IO TCP
- data TCPServer = TCPServer {}
- tcpServer :: PortNumber -> IO TCPServer
- resolve :: HostName -> IO HostAddress
Core definitions
The class for transports
runSession :: t -> TransportM a -> IO aSource
closeConnection :: t -> IO ()Source
class Transport (ServerTransport s) => Server s whereSource
type ServerTransport s Source
The underlying transport used by the server
runServer :: s -> (ServerTransport s -> IO ()) -> IO ()Source
This method should listen for incoming requests, establish some sort of a connection (represented by the transport) and then invoke the handling function
Free any resources that the server has acquired (such as the listening socket)
type TransportM = ReaderT SendPacketFn (ConduitM Packet Void IO)Source
The transport monad allows receiving packets through the conduit,
and sending functions via the provided SendPacketFn
type SendPacketFn = Packet -> IO ()Source
A function to send packets to the peer
Sending and receiving packets
sendt :: Term -> TransportM ()Source
Send a term
recvt :: TransportM (Maybe Term)Source
Receive a term
recvtForever :: (Term -> TransportM a) -> TransportM ()Source
Execute an action for every incoming term, until the connection is closed
TCP transport
The TCP transport
TCP | |
|
tcpClient :: HostName -> PortNumber -> IO TCPSource
Establish a connection to the TCP server and return the resulting transport. It can be used to make multiple requests.
The TCP server
TCPServer | |
|
tcpServer :: PortNumber -> IO TCPServerSource
A simple TCPServer
constructor, listens on all local interfaces.
If you want to bind only to some of the interfaces, create the socket manually using the functions from Network.Socket.
Utilities
resolve :: HostName -> IO HostAddressSource
A simple address resolver