Safe Haskell | None |
---|
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.
- data Gateway = Gateway {}
- type HostName = String
- data PortID
- data Signal
- = Signal {
- sigNo :: !SigNo
- sigData :: !ByteString
- | NumericSignal { }
- | NoSignal
- = Signal {
- newtype SigNo = SigNo Int32
- data SignalSelector
- data Pid
- data Timeout
- create :: String -> HostName -> PortID -> IO Gateway
- destroy :: Gateway -> IO ()
- hunt :: Gateway -> String -> Signal -> IO (Maybe Pid)
- receiveWithTimeout :: Gateway -> Timeout -> SignalSelector -> IO (Maybe (Pid, Signal))
- receive :: Gateway -> SignalSelector -> IO (Pid, Signal)
- sendWithSender :: Gateway -> Pid -> Pid -> Signal -> IO ()
- sendWithSelf :: Gateway -> Pid -> Signal -> IO ()
- attach :: Gateway -> Pid -> Signal -> IO Attref
- detach :: Gateway -> Attref -> IO ()
- askName :: Gateway -> IO String
- withGateway :: String -> HostName -> PortID -> (Gateway -> IO a) -> IO a
Documentation
Gateway instance.
Gateway | |
|
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"
.
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.
Signal | A full bodied signal with number and data. |
| |
NumericSignal | A signal data only is carrying a signal number, but no data. |
NoSignal | An |
Signal number descriptor.
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.
Timeout value.
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.
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.