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

Safe HaskellNone



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:

LINX Gateway Documentation

User's guide:

LINX protcols:

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:

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 port 21768.

 cabal configure
 cabal build
 cabal run Ping client 21768
 cabal run Ping 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.



data Gateway Source

Gateway instance.




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.


type HostName = String

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

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.



A full bodied signal with number and data.


sigNo :: !SigNo
sigData :: !ByteString

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


sigNo :: !SigNo

An empty signal.


Eq Signal 
Show Signal 
Binary Signal

Binary instances.

PayloadSize Signal

PayloadSize instances.

newtype SigNo Source

Signal number descriptor.


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.



Accept any kind of signal.


Cancel the last receive.


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


selection :: ![SigNo]

data Pid Source

Process identifier for a Linx process.


data Timeout Source

Timeout value.


Timeout Int32 


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.