Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Socket utilities.
Synopsis
- newtype AddressDescription = AddressDescription {}
- resolveAddr :: (MonadIO m, MonadFail m) => AddressDescription -> m SockAddr
- openIngress :: (Binary i, MonadIO m, MonadFail m) => AddressDescription -> ConduitT () i m ()
- openEgress :: (Binary o, MonadFail m, MonadIO m, MonadThrow m) => AddressDescription -> ConduitT o Void m ()
- openServer :: (Binary request, Binary response, MonadFail m, MonadLoggerIO m, Show request, Show response) => AddressDescription -> Maybe (IO ServerParams) -> ConduitT Void (request, response -> m Responded) m ()
- data Responded
- connectServer :: (Binary request, Binary response, MonadIO m, MonadLoggerIO n, Show response) => AddressDescription -> Maybe ClientParams -> n (request -> m response)
Socket Addresses
newtype AddressDescription Source #
A description of a socket address on which a socket is or should be listening. Supports both IPv4 and IPv6.
Examples:
AddressDescription "[::1]:80" -- IPv6 localhost, port 80 AddressDescription "127.0.0.1:80" -- IPv4 localhost, port 80 AddressDescription "somehost:80" -- IPv4 or IPv6 (depending on what name resolution returns), port 80
Instances
resolveAddr :: (MonadIO m, MonadFail m) => AddressDescription -> m SockAddr Source #
Resolve a host:port address into a SockAddr
.
Ingress-only sockets
openIngress :: (Binary i, MonadIO m, MonadFail m) => AddressDescription -> ConduitT () i m () Source #
Opens an "ingress" socket, which is a socket that accepts a stream of messages without responding.
Egress-only sockets
openEgress :: (Binary o, MonadFail m, MonadIO m, MonadThrow m) => AddressDescription -> ConduitT o Void m () Source #
Open an "egress" socket, which is a socket that sends a stream of messages without receiving responses.
Bidirection request/resposne servers.
openServer :: (Binary request, Binary response, MonadFail m, MonadLoggerIO m, Show request, Show response) => AddressDescription -> Maybe (IO ServerParams) -> ConduitT Void (request, response -> m Responded) m () Source #
Open a "server" socket, which is a socket that accepts incoming requests and provides a way to respond to those requests.
Proof that a response function was called on the server. Mainly useful for including in a type signature somewhere in your server implementation to help ensure that you actually responded to the request in all cases.
connectServer :: (Binary request, Binary response, MonadIO m, MonadLoggerIO n, Show response) => AddressDescription -> Maybe ClientParams -> n (request -> m response) Source #
Connect to a server. Returns a function in MonadIO
that can be used
to submit requests to (and returns the corresponding response from)
the server.