bert-1.2.1.2: BERT implementation

Safe HaskellNone

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.

Synopsis

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.

tcpServer :: PortNumber -> IO TCPServerSource

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.