Safe Haskell | None |
---|
- sourceSocket :: MonadIO m => Socket -> Producer m ByteString
- sinkSocket :: MonadIO m => Socket -> Consumer ByteString m ()
- type Application m = AppData m -> m ()
- data AppData m
- appSource :: AppData m -> Source m ByteString
- appSink :: AppData m -> Sink ByteString m ()
- data ServerSettings m
- serverSettings :: Monad m => FilePath -> ServerSettings m
- serverPath :: ServerSettings m -> FilePath
- serverAfterBind :: ServerSettings m -> Socket -> m ()
- runUnixServer :: (MonadIO m, MonadBaseControl IO m) => ServerSettings m -> Application m -> m ()
- data ClientSettings m
- clientSettings :: Monad m => FilePath -> ClientSettings m
- clientPath :: ClientSettings m -> FilePath
- runUnixClient :: (MonadIO m, MonadBaseControl IO m) => ClientSettings m -> Application m -> m ()
- bindPath :: FilePath -> IO Socket
- getSocket :: FilePath -> IO Socket
- acceptSafe :: Socket -> IO (Socket, SockAddr)
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 server/client interface
type Application m = AppData m -> m ()Source
A simple Unix domain sockets application.
Since 1.0.2
appSource :: AppData m -> Source m ByteStringSource
appSink :: AppData m -> Sink ByteString m ()Source
Server
data ServerSettings m Source
Settings for a Unix domain sockets server.
Since 1.0.2
:: Monad m | |
=> FilePath | path to bind to |
-> ServerSettings m |
Smart constructor.
Since 1.0.2
serverPath :: ServerSettings m -> FilePathSource
serverAfterBind :: ServerSettings m -> Socket -> m ()Source
runUnixServer :: (MonadIO m, MonadBaseControl IO m) => ServerSettings m -> Application m -> m ()Source
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 1.0.2
Client
data ClientSettings m Source
Settings for a Unix domain sockets client.
Since 1.0.2
:: Monad m | |
=> FilePath | path to connect to |
-> ClientSettings m |
Smart constructor.
Since 1.0.2
clientPath :: ClientSettings m -> FilePathSource
runUnixClient :: (MonadIO m, MonadBaseControl IO m) => ClientSettings m -> Application m -> m ()Source
Run an Application
by connecting to the specified server.
Since 1.0.2
Helper utilities
bindPath :: FilePath -> IO SocketSource
Attempt to bind a listening Unix domain socket at the given path.
Since 1.0.2
acceptSafe :: Socket -> IO (Socket, SockAddr)Source
Try to accept a connection, recovering automatically from exceptions.
As reported by Kazu against Warp, resource exhausted (Too many open files) may be thrown by accept(). This function will catch that exception, wait a second, and then try again.
Since 0.6.0