iterio-server-0.3: Library for building servers with IterIO

Safe HaskellSafe-Infered



Generic building blocks for creating TCP Servers based on IterIO



data TCPServer inp m Source

TCPServer holds all the information necessary to run bind to a sock and respond to TCP requests from the network.




serverPort :: PortNumber

The TCP port the server will listen for incomming connections on.

serverHandler :: Inum inp inp m ()

This Inum implements the actual functionality of the server. The input and output of the Inum correspond to the input and output of the socket.

serverAcceptor :: Socket -> m (Iter inp m (), Onum inp m ())

A function to transform an accept incomming connection into an iter and onum. Most servers should just use defaultSocketAcceptor but this can be used for special cases, e.g. accepting SSL connections with iterSSL.

serverResultHandler :: m () -> IO ()

Must execute the monadic result. Servers operating in the IO Monad can use id.


Show (TCPServer inp m) 

runTCPServer :: (ListLikeIO inp e, ChunkData inp, Monad m) => TCPServer inp m -> IO ()Source

Runs a TCPServer in a loop.

defaultServerAcceptor :: (ListLikeIO inp e, ChunkData inp, MonadIO m) => Socket -> m (Iter inp m (), Onum inp m a)Source

This acceptor creates an Iter and Onum using handleI and enumHandle respectively.

minimalTCPServer :: (ListLikeIO inp e, ChunkData inp) => TCPServer inp IOSource

For convenience, a TCPServer in the IO Monad with null defaults:

simpleHttpServer :: PortNumber -> HttpRequestHandler IO () -> TCPServer ByteString IOSource

Creates a simple HTTP server from an HTTPRequestHandler.

echoServer :: PortNumber -> TCPServer String IOSource

Creates a TCPServer that echoes each line from the client until EOF.