Safe Haskell | None |
---|
- 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 ()
- runTCPServerWithHandle :: ServerSettings -> ConnectionHandle -> IO ()
- data ClientSettings
- clientSettings :: Int -> ByteString -> ClientSettings
- runTCPClient :: ClientSettings -> (AppData -> IO a) -> IO 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 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.
appSource :: (HasReadWrite ad, MonadIO m) => ad -> Producer m ByteStringSource
appSink :: (HasReadWrite ad, MonadIO m) => ad -> Consumer ByteString m ()Source
appSockAddr :: AppData -> SockAddr
appLocalAddr :: AppData -> Maybe SockAddr
Server
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.
runTCPServerWithHandle :: ServerSettings -> ConnectionHandle -> IO ()
Client
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.
Getters
getHost :: ClientSettings -> ByteString
getAfterBind :: HasAfterBind a => a -> Socket -> IO ()
Setters
setHost :: ByteString -> ClientSettings -> ClientSettings
setAfterBind :: HasAfterBind a => (Socket -> IO ()) -> a -> a
setNeedLocalAddr :: Bool -> ServerSettings -> ServerSettings
Types
data HostPreference
Which host to bind.
Note: The IsString
instance recognizes the following special values:
-
*
meansHostAny
-
*4
meansHostIPv4
-
!4
meansHostIPv4Only
-
*6
meansHostIPv6
-
!6
meansHostIPv6Only