network-conduit-1.0.4: Stream socket data using conduits.

Safe HaskellNone

Data.Conduit.Network.Unix

Contents

Synopsis

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

data AppData m Source

The data passed to a Unix domain sockets Application.

Since 1.0.2

Server

data ServerSettings m Source

Settings for a Unix domain sockets server.

Since 1.0.2

serverSettingsSource

Arguments

:: Monad m 
=> FilePath

path to bind to

-> ServerSettings m 

Smart constructor.

Since 1.0.2

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

clientSettingsSource

Arguments

:: Monad m 
=> FilePath

path to connect to

-> ClientSettings m 

Smart constructor.

Since 1.0.2

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

getSocket :: FilePath -> IO SocketSource

Attempt to connect to the given Unix domain socket path.

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