Portability | portable |
---|---|
Stability | experimental |
Maintainer | Sebastian Reese (str@holumbus.org) |
Version : 0.1
This module provides an interface to start a server listeing on a tcp socket. ( Module is based on simple tcp server found here http:sequence.complete.orgnode258 )
You have to implement 2 functions type ServerAction a = a -> Client a -> [Client a] -> IO [Client a]
and
type LineConverter a = String -> a
to start a server use the doWithServer :: (Show a) => Int -> ServerAction a -> LineConverter a -> String -> IO () function.
- data Client a = Client (TChan a) Handle HostName PortNumber
- type ServerAction a = a -> Client a -> [Client a] -> IO [Client a]
- type LineConverter a = String -> a
- doWithServer :: Show a => Int -> ServerAction a -> LineConverter a -> String -> IO ()
Documentation
the connecting client type
type ServerAction a = a -> Client a -> [Client a] -> IO [Client a]Source
type for call back function that is executed within server cycle
type LineConverter a = String -> aSource
converts the string read by hGetLine to your datatype
doWithServer :: Show a => Int -> ServerAction a -> LineConverter a -> String -> IO ()Source
execute a ServerAction wrapped by the tcp server