Infrasctucture SerTcp Function Reference

SerTcp
#include "serTcp.h"

The serial TCP module allows socket I/O to a remote host and port, such as you would need for telnet.    Serial I/O is a conversational API in that the serving divice expects ascii input and responds with ascii.    Internally the socket is non-blocking but sioSndRcv is a blocking call while allowing all other socket I/O, alarms, events, etc.    Up to 25 (configurable) sockets/sessions may be open at once.    An integer handle is used to indicate which socket to use.

sioClose sioInit sioGetSock sioOpen sioSetFlg sioSndRcv
sioSndRcvB

int sioClose( int handle )
Closes/disconects the socket and frees all control blocks.


int sioInit( int argc, char* argv )
Allows the serial I/O layer to register configuration variables and must be called before any other sio calls.    Returns argc (possible modified if this process used any command line variables).


int sioGetSock( int handle )
Return the socket used for this connection (ofr use by dConn()).   


int sioOpen( char* host, char* port, int maxDat )
Opens the connection to the specified host and port.    The "host" and "port" args determine the network host and the port.    The arg "maxDat" determines how much space will be allocated for transmit and receive buffers.    Returns a positive integer connection handle (greater than zero) else a negative error code.


int sioSetFlg( int handle, int flag )
Set acontrol flag for sioSndRcv.    Currently you may set ASCIIFLG to eliminate NULLs from input data.


int sioSndRcv( int handle, char* inputBuf, char* match, int maxRx, int timeOut, char* outMsgFmt, va_args ... )
Formats and transmitts the output message over the connection, then conditionally waits for the input message.    The input message is terminated in one of three ways, by matching the 'match' string, the input character count reaches 'maxRx', or 'timeOut' (in milliseconds) expires.    If 'maxRx' is zero no characters will be received (only want to send).    Returns the count of characters stored in the input buffer ("inputBuf").


int sioSndRcvB( int handle, char* inputBuf, char* match, int maxRx, int timeOut, int outDatLen, uchar* outDat )
Transmitts a binary output message ("ouDat") of length "outDatLen" over the connection, then conditionally waits for the input message.    The input message is terminated in one of three ways, by matching the 'match' string, the input character count reaches 'maxRx', or 'timeOut' (in milliseconds) expires.    If 'maxRx' is zero no characters will be received (only want to send).    Returns the count of characters stored in the input buffer ("inputBuf").