Holumbus-Distribution-0.1.1: intra- and inter-program communication

Portabilityportable
Stabilityexperimental
MaintainerStefan Schmidt (stefanschmidt@web.de)

Holumbus.Distribution.DNode.Network

Contents

Description

Version : 0.1

The Server-Module for the Holumbus framework.

It contains the lowlevel functions, like the socket handling (opening, reading, writing, ...).

Synopsis

Server-Datatypes

Server-Operations

startSocketServerSource

Arguments

:: HandlerFunction ()

dispatcher function

-> Int

start port number

-> Int

end port number

-> IO (Maybe SocketServer) 

Creates a new (unix-)socket and starts the listener in its own thread. You'll get a reference to the listener Thread, so you can kill it with stopSocketServer. It is also possible to give a range of PortNumbers on which the socket will be opened. The first portnumber available will be taken.

stopSocketServer :: SocketServer -> IO ()Source

Stops a socker server by its internal thread id.

Client-Operations

Handle-Operations

putByteStringMessage :: ByteString -> Handle -> IO ()Source

Puts a bytestring to a handle. But to make the reading easier, we write the length of the data as a message-header to the handle, too.

getByteStringMessage :: Handle -> IO ByteStringSource

Reads data from a stream. We define, that the first line of the message is the message header which tells us how much bytes we have to read.