Infrasctucture TcpSrv Function Reference

TcpSrv
#include      "tcpSrv.h"
The TcpSrv module allows the programmer to create a TCP server or, in the interest of symmetry, connect to another process running a TCP Server.    The TcpSrv paradigm allows an open (tsOpen) followed by a send (tsSnd) or receive (tsRcv).   

tsClose     tsInit     tsOpen     tsRcv     tsSnd    

int  tsClose( int handle )
Close all sockets and clean up.    Returns OK.

int  tsInit( int argc, char** argv )
Prepares TcpSrv for initialiazation.    Returns argc.

int  tsOpen( char* host, char* port, int maxDat, int srvFlg )
Create control block, with input and output buffers, a base socket with host and port assigned.    If srvFlg is TRUE, bind a name to the socket and listen.    Returns a handle for use with all following operations on this socket else negative of errno.

int  tsRcv( int handle, char* rcvDat, char* match, int maxRx, int to )
Receive characters until either the character count reaches "maxRx" or the "match" pattern is found in the received data or the time out "to" expires.    Returns bytes received or an error (negative of errno) or zero if timed out.

int  tsSnd( int handle, int to, int txLen, uchar* txDat )
Transmit the characters indicated by "txDat" and of length "txLen".    If the socket is not yet connected, it will be connected to the previously indicated host and port (tsOpen()).    Returns bytes transmitted or an error (negative of errno) or zero if timed out.