conduit-extra- Batteries included conduit: adapters for common libraries.

Safe HaskellNone




Basic utilities

sourceSocket :: MonadIO m => Socket -> Producer m ByteStringSource

Stream data from the socket.

This function does not automatically close the socket.

Since 0.0.0

sinkSocket :: MonadIO m => Socket -> Consumer ByteString m ()Source

Stream data to the socket.

This function does not automatically close the socket.

Since 0.0.0

Simple TCP server/client interface.

data AppData

The data passed to an Application.

appSource :: (HasReadWrite ad, MonadIO m) => ad -> Producer m ByteStringSource

appSink :: (HasReadWrite ad, MonadIO m) => ad -> Consumer ByteString m ()Source


data ServerSettings

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

runTCPServer :: ServerSettings -> (AppData -> IO ()) -> 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.

forkTCPServer :: MonadBaseControl IO m => ServerSettings -> (AppData -> m ()) -> m ThreadIdSource

Fork a TCP Server

Will fork the runGeneralTCPServer function but will only return from this call when the server is bound to the port and accepting incoming connections. Will return the thread id of the server

Since 1.1.4

runGeneralTCPServer :: MonadBaseControl IO m => ServerSettings -> (AppData -> m ()) -> m ()Source

Run a general TCP server

Same as runTCPServer, except monad can be any instance of MonadBaseControl IO.

Note that any changes to the monadic state performed by individual client handlers will be discarded. If you have mutable state you want to share among multiple handlers, you need to use some kind of mutable variables.

Since 1.1.3


data ClientSettings

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

clientSettings :: Int -> ByteString -> ClientSettingsSource

runTCPClient :: ClientSettings -> (AppData -> IO a) -> IO a

Run an Application by connecting to the specified server.

runGeneralTCPClient :: MonadBaseControl IO m => ClientSettings -> (AppData -> m a) -> m aSource

Run a general TCP client

Same as runTCPClient, except monad can be any instance of MonadBaseControl IO.

Since 1.1.3


getPort :: HasPort a => a -> Int

getHost :: ClientSettings -> ByteString

getAfterBind :: HasAfterBind a => a -> Socket -> IO ()


setPort :: HasPort a => Int -> a -> a

setAfterBind :: HasAfterBind a => (Socket -> IO ()) -> a -> a


data HostPreference

Which host to bind.

Note: The IsString instance recognizes the following special values:

  • * means HostAny
  • *4 means HostIPv4
  • !4 means HostIPv4Only
  • *6 means HostIPv6
  • !6 means HostIPv6Only

Any other values is treated as a hostname. As an example, to bind to the IPv4 local host only, use "".