Safe Haskell | None |
---|---|
Language | Haskell98 |
Data.Conduit.Network
- sourceSocket :: MonadIO m => Socket -> Producer m ByteString
- sinkSocket :: MonadIO m => Socket -> Consumer ByteString m ()
- data AppData :: *
- appSource :: (HasReadWrite ad, MonadIO m) => ad -> Producer m ByteString
- appSink :: (HasReadWrite ad, MonadIO m) => ad -> Consumer ByteString m ()
- appSockAddr :: AppData -> SockAddr
- appLocalAddr :: AppData -> Maybe SockAddr
- data ServerSettings :: *
- serverSettings :: Int -> HostPreference -> ServerSettings
- runTCPServer :: ServerSettings -> (AppData -> IO ()) -> IO a
- runTCPServerWithHandle :: ServerSettings -> ConnectionHandle -> IO a
- forkTCPServer :: MonadBaseControl IO m => ServerSettings -> (AppData -> m ()) -> m ThreadId
- runGeneralTCPServer :: MonadBaseControl IO m => ServerSettings -> (AppData -> m ()) -> m a
- data ClientSettings :: *
- clientSettings :: Int -> ByteString -> ClientSettings
- runTCPClient :: ClientSettings -> (AppData -> IO a) -> IO a
- runGeneralTCPClient :: MonadBaseControl IO m => ClientSettings -> (AppData -> m a) -> m a
- getPort :: HasPort a => a -> Int
- getHost :: ClientSettings -> ByteString
- getAfterBind :: HasAfterBind a => a -> Socket -> IO ()
- getNeedLocalAddr :: ServerSettings -> Bool
- setPort :: HasPort a => Int -> a -> a
- setHost :: ByteString -> ClientSettings -> ClientSettings
- setAfterBind :: HasAfterBind a => (Socket -> IO ()) -> a -> a
- setNeedLocalAddr :: Bool -> ServerSettings -> ServerSettings
- data HostPreference :: *
Basic utilities
sourceSocket :: MonadIO m => Socket -> Producer m ByteString #
Stream data from the socket.
This function does not automatically close the socket.
Since 0.0.0
sinkSocket :: MonadIO m => Socket -> Consumer ByteString m () #
Stream data to the socket.
This function does not automatically close the socket.
Since 0.0.0
Simple TCP server/client interface.
appSource :: (HasReadWrite ad, MonadIO m) => ad -> Producer m ByteString #
appSink :: (HasReadWrite ad, MonadIO m) => ad -> Consumer ByteString m () #
appSockAddr :: AppData -> SockAddr #
appLocalAddr :: AppData -> Maybe SockAddr #
Server
data ServerSettings :: * #
Instances
HasReadBufferSize ServerSettings | |
HasPort ServerSettings | |
HasAfterBind ServerSettings | |
serverSettings :: Int -> HostPreference -> ServerSettings #
runTCPServer :: ServerSettings -> (AppData -> IO ()) -> IO a #
runTCPServerWithHandle :: ServerSettings -> ConnectionHandle -> IO a #
forkTCPServer :: MonadBaseControl IO m => ServerSettings -> (AppData -> m ()) -> m ThreadId #
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 a #
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
Client
data ClientSettings :: * #
Instances
HasReadBufferSize ClientSettings | |
HasPort ClientSettings | |
clientSettings :: Int -> ByteString -> ClientSettings #
runTCPClient :: ClientSettings -> (AppData -> IO a) -> IO a #
runGeneralTCPClient :: MonadBaseControl IO m => ClientSettings -> (AppData -> m a) -> m a #
Run a general TCP client
Same as runTCPClient
, except monad can be any instance of MonadBaseControl
IO
.
Since 1.1.3
Getters
getHost :: ClientSettings -> ByteString #
getAfterBind :: HasAfterBind a => a -> Socket -> IO () #
getNeedLocalAddr :: ServerSettings -> Bool #
Setters
setHost :: ByteString -> ClientSettings -> ClientSettings #
setAfterBind :: HasAfterBind a => (Socket -> IO ()) -> a -> a #
setNeedLocalAddr :: Bool -> ServerSettings -> ServerSettings #
Types
data HostPreference :: * #