Carapace

Util Comms Module

The Util module provides useful communications services -- such as receiving data until a given string is found. It is a 'translation' module since it manipulates its sent/received data.

Util Creation

The create function can be used to create a Util module eg.

    (create Util)
Once created, this module is tailored using its properties and methods.

Util Properties

A Util module supports the following properties:

property name property type description
readParity String parity to impose upon received data -- values are one of: odd, even, strip or preserve
writeParity String parity to impose upon data sent -- values are one of: odd, even, strip or preserve
log Log a log for the communications
trafficGroup String traffic statistics for data transmitted through a Util comms module can be collected for a group of such modules -- this is the traffic group. Statistics are gathered for all Util modules within the same traffic group and can be returned using the traffic method.
inactivityTimeout Integer the inactivity timeout value (seconds) for the session -- NOTE: this value stored so that a script accessing the module can take the appropriate action: the module does not set a timer to disconnect the session automatically

Util Methods

The Util module supports the following methods:

method name description
receiveN attempt to receive exactly the supplied no. of bytes
receiveUntil receive data until the supplied string is received
traffic returns a CommsInfo object for all data collected for the supplied traffic group
resetTraffic resets the CommsInfo object for all data collected for the supplied traffic group

The standard comms module methods are also supported:

method name description
connect connect this module
receive receive data
receiveInto receive data into the supplied buffer
send send data
disconnect disconnect this module
bind bind address information for this module
listen prepare to listen for new connections
accept wait for a new connection to arrive and, if it does, accept it


receiveN

Attempt to receive exactly the supplied no. of bytes.

Arguments:

nToReadInteger
timeoutInteger

Return type: Binary -- an error is raised if insufficient data is received in time.


receiveUntil

Receive data until the supplied string is received.

Arguments:

testString
timeoutInteger

Return type: Binary -- an error is raised if insufficient data is received in time.


traffic

Returns a CommsInfo object for all data collected for the supplied traffic group.

Arguments:

groupNameString

Return type: CommsInfo

resetTraffic

Resets the CommsInfo object for all data collected for the supplied traffic group.

Arguments:

groupNameString

Return type: the empty List


Contents Index Current topic: communications Related topics: communications classes, objects