Holumbus-Distribution-0.0.1.1: intra- and inter-program communicationSource codeContentsIndex
Holumbus.Network.Communication
Portabilityportable
Stabilityexperimental
MaintainerStefan Schmidt (stefanschmidt@web.de)
Contents
server operations
client operations
Description

Version : 0.1

This module implements an abstract client server model. The clients register at the server and check from time to time if the server still exists. If not, the client searches for a new server. The server on the other hand, keeps a list with all clients and checks, if each client is reachable. If not, the client is deleted from the list.

This abstract network model helps us to implement a basic distrubuted system with a central server and many attached clients which get little tasks from the server. Because this model alone would be very unfunctional, the user is able to define his own functions which will be handled by the server or the client.

Synopsis
type StreamName = String
data SocketId
PortNumber (PortNum)
time30 :: Int
timeIndefinitely :: Int
type IdType = Int
data ClientInfo = ClientInfo {
ci_Id :: Int
ci_Site :: SiteId
ci_Port :: ClientPort
ci_PingThreadId :: Thread
ci_LifeValue :: Int
}
data Server
newServer :: (Binary a, Binary b) => StreamName -> Maybe PortNumber -> (a -> IO (Maybe b)) -> Maybe RegistrationAction -> Maybe RegistrationAction -> IO Server
closeServer :: Server -> IO ()
data ServerPort
newServerPort :: StreamName -> Maybe SocketId -> IO ServerPort
sendRequestToServer :: (Show a, Binary a, Binary b) => ServerPort -> Int -> a -> (b -> IO (Maybe c)) -> IO c
getClientInfo :: IdType -> Server -> IO (Maybe ClientInfo)
getAllClientInfos :: Server -> IO [ClientInfo]
class ClientClass c where
pingClient :: IdType -> c -> IO Bool
getClientId :: c -> IO (Maybe IdType)
getServerPort :: c -> IO ServerPort
data Client
newClient :: (Binary a, Binary b) => StreamName -> Maybe SocketId -> (a -> IO (Maybe b)) -> IO Client
closeClient :: Client -> IO ()
data ClientPort
sendRequestToClient :: (Show a, Binary a, Binary b) => ClientPort -> Int -> a -> (b -> IO (Maybe c)) -> IO c
Documentation
type StreamName = StringSource
The name of a stream.
data SocketId Source
All data, that is needed to address a socket. Contains the hostname and the portNumber.
show/hide Instances
PortNumber (PortNum)
time30 :: IntSource
30 seconds
timeIndefinitely :: IntSource
Wait how long it takes
type IdType = IntSource
The type of the client id.
data ClientInfo Source
Constructors
ClientInfo
ci_Id :: Int
ci_Site :: SiteIdSiteId (Hostname,PID) of the client process
ci_Port :: ClientPortthe port of the client
ci_PingThreadId :: Threadthe threadId of the ping-Process (needed to stop it)
ci_LifeValue :: Int
show/hide Instances
server operations
data Server Source
The server.
show/hide Instances
Debug Server
ServerClass Server
newServerSource
:: (Binary a, Binary b)
=> StreamName
-> Maybe PortNumber
-> a -> IO (Maybe b)handling own request
-> Maybe RegistrationActionfor registration
-> Maybe RegistrationActionfor unregistration
-> IO Server
Creates a new server.
closeServer :: Server -> IO ()Source
Closes the server.
data ServerPort Source
The ServerPort is only a wrapper for a Port-Datatype.
show/hide Instances
newServerPort :: StreamName -> Maybe SocketId -> IO ServerPortSource
Creates a new ServerPort.
sendRequestToServerSource
:: (Show a, Binary a, Binary b)
=> ServerPort
-> Int
-> a
-> b -> IO (Maybe c)response handler
-> IO c
Sends a request from the client to the server an handles the response or invokes a user-defined handler.
getClientInfo :: IdType -> Server -> IO (Maybe ClientInfo)Source
Gets the ClientPort from a ClientId (on the Server).
getAllClientInfos :: Server -> IO [ClientInfo]Source
Gets a list with all registered clients (on the Server).
client operations
class ClientClass c whereSource
The request-functions a client has to implement.
Methods
pingClient :: IdType -> c -> IO BoolSource
Check, if the client is responding.
getClientId :: c -> IO (Maybe IdType)Source
Get the ID of the client.
getServerPort :: c -> IO ServerPortSource
Gets the server port the client wants to connect to.
show/hide Instances
data Client Source
Only a wrapper around an MVar.
show/hide Instances
newClientSource
:: (Binary a, Binary b)
=> StreamName
-> Maybe SocketId
-> a -> IO (Maybe b)the individual request dispatcher for the client
-> IO Client
Creates a new client, it needs the StreamName and optional the SocketId of the server.
closeClient :: Client -> IO ()Source
Closes the client.
data ClientPort Source
Just a wrapper around a port.
show/hide Instances
sendRequestToClientSource
:: (Show a, Binary a, Binary b)
=> ClientPort
-> Int
-> a
-> b -> IO (Maybe c)response handler
-> IO c
Sends a request from the server to the client an handles the response or invokes a user-defined handler.
Produced by Haddock version 2.4.2