Safe Haskell | None |
---|---|
Language | Haskell2010 |
Network.BERT.Server
Contents
Description
BERT-RPC server (http://bert-rpc.org/). This implements the client RPC call/reply logic. Only synchronous requests are supported at this time.
- serve :: Server s => s -> (String -> String -> [Term] -> IO DispatchResult) -> IO ()
- data DispatchResult
- tcpServer :: PortNumber -> IO TCPServer
Example
To serve requests, create a server and call serve
with a
dispatch function.
main = do s <- tcpServer 8080 serve s dispatch dispatch "calc" "add" [IntTerm a, IntTerm b] = return $ Success $ IntTerm (a + b) dispatch "calc" _ _ = return NoSuchFunction dispatch _ _ _ = return NoSuchModule
serve :: Server s => s -> (String -> String -> [Term] -> IO DispatchResult) -> IO () Source
Serve from the given transport (forever), handling each request with the given dispatch function in a new thread.
data DispatchResult Source
Constructors
Success Term | |
NoSuchModule | |
NoSuchFunction | |
Undesignated String |
tcpServer :: PortNumber -> IO TCPServer Source
A simple TCPServer
constructor, listens on all local interfaces.
If you want to bind only to some of the interfaces, create the socket manually using the functions from Network.Socket.