linx-gateway-0.1.0.2: Implementation of the Enea LINX gateway protocol.

Safe HaskellNone

Network.Linx.Gateway

Description

Implementation of the Enea LINX Gateway protocol in Haskell. More information about LINX and the LINX Gateway can be found on its project page on Sourceforge: http://sourceforge.net/projects/linx/

LINX Gateway Documentation

User's guide: http://linx.sourceforge.net/linxdoc/doc/usersguide/UsersGuide_LINX_Gateway.html

LINX protcols: http://linx.sourceforge.net/linxdoc/doc/linxprotocols/book-linx-protocols-html/index.html

Example application

Bundled with this software package is an example application consisting of one ping server program and one ping client program. The example programs are demonstrating several aspects of the gateway API.

The code can be browsed in the examples directory at the project's GitHub: https://github.com/kosmoskatten/linx-gateway

In order to run the examples a LINX Gateway server must be setup and be available in your IP network. For the samples below the gateway server is running at 192.168.122.8 port 21768.

 cabal configure
 cabal build
 cabal run Ping client 192.168.122.8 21768
 cabal run Ping 192.168.122.8 21768

The order in which the server and the client is started is not important. The client is also supervising the server, so if the server is terminated the client is trying to reconnect to the server again once it's restarted.

Several clients can be started.

Synopsis

Documentation

data Gateway Source

Gateway instance.

Constructors

Gateway 

Fields

handle :: !Handle

The socket handle towards the gateway server.

self :: !Pid

The LINX Pid of the gateway instance.

maxSignal :: !Length

The max length of a Signal payload the gateway server is accepting.

accept :: ![PayloadType]

The type of operations in the gateway protocol that the gateway server is accepting.

Instances

type HostName = String

Either a host name e.g., "haskell.org" or a numeric host address string consisting of a dotted decimal IPv4 address or an IPv6 address e.g., "192.168.0.1".

data Signal Source

A signal - user lever payload data - is coded into three different fields in the gateway protocol: Signal length in bytes, including signal number. Signal number. Array of signal data. Even in the case of NoSignal the binary encoding is eight bytes.

Constructors

Signal

A full bodied signal with number and data.

Fields

sigNo :: !SigNo
 
sigData :: !ByteString
 
NumericSignal

A signal data only is carrying a signal number, but no data.

Fields

sigNo :: !SigNo
 
NoSignal

An empty signal.

Instances

Eq Signal 
Show Signal 
Binary Signal

Binary instances.

PayloadSize Signal

PayloadSize instances.

newtype SigNo Source

Signal number descriptor.

Constructors

SigNo Int32 

data SignalSelector Source

A signal selector is used to filter which signals to expect when calling receive. It can either be one of two specific filters - AnySignal or Cancel - or a generic filter.

Constructors

AnySignal

Accept any kind of signal.

Cancel

Cancel the last receive.

Sel

Accept any of the specified signals. The list must not be empty.

Fields

selection :: ![SigNo]
 

data Pid Source

Process identifier for a Linx process.

Instances

data Timeout Source

Timeout value.

Constructors

Infinity 
Timeout Int32 

Instances

Eq Timeout 
Show Timeout 
Binary Timeout

Binary instance for Timeout.

create :: String -> HostName -> PortID -> IO GatewaySource

Create a new client instance in the gateway. The gateway is addressed by a hostname and a port id.

destroy :: Gateway -> IO ()Source

Destroy a client.

hunt :: Gateway -> String -> Signal -> IO (Maybe Pid)Source

Ask the gateway server to execute a hunt call. If the hunted process is available at the moment of the hunt its pid is returned immediately.

receiveWithTimeout :: Gateway -> Timeout -> SignalSelector -> IO (Maybe (Pid, Signal))Source

Ask the gateway server to execute a receive call with the specified timeout value. If no signal is received within the time the value of Nothing is returned.

receive :: Gateway -> SignalSelector -> IO (Pid, Signal)Source

Ask the gateway server to execute a receive call with infinitely long waiting time.

sendWithSender :: Gateway -> Pid -> Pid -> Signal -> IO ()Source

Ask the gateway server to execute a send_w_s call.

sendWithSelf :: Gateway -> Pid -> Signal -> IO ()Source

Ask the gateway server to execute a send call_w_s call where the sender is the pid stored in the gateway record.

attach :: Gateway -> Pid -> Signal -> IO AttrefSource

Ask the gateway server to execute an attach call.

detach :: Gateway -> Attref -> IO ()Source

Ask the gateway server to execute a detach call.

askName :: Gateway -> IO StringSource

Ask the gateway server about its name.

withGateway :: String -> HostName -> PortID -> (Gateway -> IO a) -> IO aSource

Convenience function to handle acquire and release semantics for creating and destroying a gateway instance.