pipes-extra-0.0.1: Pipes utilities

Control.Pipe.Network

Synopsis

Documentation

type Application = Producer ByteString (ResourceT IO) () -> Consumer ByteString (ResourceT IO) () -> ResourceT IO ()

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

sourceSocket :: MonadIO m => Socket -> Producer ByteString m ()

Stream data from the socket.

sinkSocket :: MonadIO m => Socket -> Consumer ByteString m r

Stream data to the socket.

data ServerSettings

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 :: ServerSettings -> Application -> IO ()

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

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

Constructors

ClientSettings 

runTCPClient :: ClientSettings -> Application -> IO ()

Run an Application by connecting to the specified server.