| Safe Haskell | None |
|---|
Data.Conduit.Network
- sourceSocket :: MonadIO m => Socket -> Source m ByteString
- sinkSocket :: MonadIO m => Socket -> Sink ByteString m ()
- type Application m = Source m ByteString -> Sink ByteString m () -> m ()
- data ServerSettings = ServerSettings {}
- runTCPServer :: (MonadIO m, MonadBaseControl IO m) => ServerSettings -> Application m -> m ()
- data ClientSettings = ClientSettings {
- clientPort :: Int
- clientHost :: String
- runTCPClient :: (MonadIO m, MonadBaseControl IO m) => ClientSettings -> Application m -> m ()
- data HostPreference
- bindPort :: Int -> HostPreference -> IO Socket
- getSocket :: String -> Int -> IO Socket
Basic utilities
sourceSocket :: MonadIO m => Socket -> Source m ByteString
Stream data from the socket.
This function does not automatically close the socket.
Since 0.0.0
sinkSocket :: MonadIO m => Socket -> Sink ByteString m ()
Stream data to the socket.
This function does not automatically close the socket.
Since 0.0.0
Simple TCP server/client interface.
type Application m = Source m ByteString -> Sink ByteString m () -> m ()
A simple TCP application. It takes two arguments: the Source to read
input data from, and the Sink to send output data to.
Since 0.3.0
Server
data ServerSettings
Settings for a TCP server. It takes a port to listen on, and an optional hostname to bind to.
Since 0.3.0
Constructors
| ServerSettings | |
Fields | |
Instances
runTCPServer :: (MonadIO m, MonadBaseControl IO m) => ServerSettings -> Application m -> m ()
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.
Since 0.3.0
Client
data ClientSettings
Settings for a TCP client, specifying how to connect to the server.
Since 0.2.1
Constructors
| ClientSettings | |
Fields
| |
Instances
runTCPClient :: (MonadIO m, MonadBaseControl IO m) => ClientSettings -> Application m -> m ()
Run an Application by connecting to the specified server.
Since 0.2.1
Helper utilities
data HostPreference
Which host to bind.
Note: The IsString instance recognizes the following special values:
-
*meansHostAny -
*4meansHostIPv4 -
*6meansHostIPv6
bindPort :: Int -> HostPreference -> IO Socket
Attempt to bind a listening Socket on the given host/port. If no host is
given, will use the first address available.
Since 0.3.0