pipes-network-0.0.2: Utilities to deal with sockets.

Safe HaskellSafe-Infered

Control.Pipe.Network

Synopsis

Documentation

type Application m r = Pipe () ByteString m () -> Pipe ByteString Void m () -> IO rSource

A simple TCP application. It takes two arguments: the Producer to read input data from, and the Consumer to send output data to.

socketReader :: MonadIO m => Socket -> Pipe () ByteString m ()Source

Stream data from the socket.

socketWriter :: MonadIO m => Socket -> Pipe ByteString Void m rSource

Stream data to the socket.

data ServerSettings Source

Settings for a TCP server. It takes a port to listen on, and an optional hostname to bind to.

Constructors

ServerSettings 

Fields

serverPort :: Int
 
serverHost :: Maybe String

Nothing indicates no preference

runTCPServer :: MonadIO m => ServerSettings -> Application m r -> IO rSource

Run an Application with the given settings. This function will create a new listening socket, accept connections on it, and spawn a new thread for each connection.

data ClientSettings Source

Settings for a TCP client, specifying how to connect to the server.

Constructors

ClientSettings 

runTCPClient :: MonadIO m => ClientSettings -> Application m r -> IO rSource

Run an Application by connecting to the specified server.