Infrasctucture Io2 Function Reference

Io2
#include      "io2.h"
The Io2 module allows the programmer to send and receive data vi TCP, UDP and Serial COM port.    The Io2 paradigm allows an open (io2Open) followed by a send or receive followed by a close.   

io2Close     io2Init     io2Open     io2Rcv     io2SetFlg     io2Snd    
io2Stop     io2StrtRx     io2StrtTx    

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

int  io2Init( int argc, char** argv )
Prepares Io2 for initialiazation.    Returns argc.

int  io2Open( int type, char* host, char* port, int maxDat )
Create control block, with input and output buffers, a base socket with "host" and "port" assigned.    The "maxDat" establishes send/recieve buffer size.    If "maxDat" is zero a default buffer sizeof 8192 is used.    The "type" sets the protocol and establishes connections automatically.    The Type codes are:
IO2TCPC    use TCP as a client (connect to remote host).
IO2TCPS    use TCP as a server (bind address and wait for connection).
IO2UDPC    use UDP as a client (establish bidirectional path to remote host).
IO2UDPS    use UDP as a server (bind address and wait for in-bound packets).
IO2SER    use SERIAL DEVICE.
IO2CONS    user the process' console.   
Returns a handle for use with all following operations on this session else negative of errno.

int  io2Rcv( int handle, char* rcvDat, char* match, int maxRx, int rFlg, 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" (in milliseconds) expires.    In the UDP mode the "rFlg" allows multiple reads of a UDP pkt, as in reading the header (rFlg = TRUE) to get the overall len and then re-read the entire packet (rFlg = FALSE.    Returns byte count received or an error (negative of errno) or zero if timed out.

int  io2SetFlg( int handle, int flagBits )
Set the session flags per the supplied "flagBits" argument.    The flag bit defines are:
IO2NONULL    Convert input nulls into spaces for Pix Firewall.
IO2BIN   If FALSE (assume ASCII data) put a null at end of recv'd data.

int  io2Snd( int handle, int to, int txLen, char* fmt, elipsis* ... )
If txLen is zero transmit the characters indicated by "fmt" expanded any following arguments.    If txLen is not zero it is assumed to be binary data and no expansion is attempted.    The process waits "to" milliseconds for the transmitt to complete and if the time expires returns a zero.    Returns byte count transmitted or an error (negative of errno) or zero if timed out.

int  io2Stop( int handle )
Stop any I/O snd or rcv already running.    Used to stop the main after a complete callback.

int  io2StrtRx( int handle, char* rcvDat, char* match, int maxRx, int rFlg, pfi_t callBack )
This call and io2StrtTx allow the program to receive characters while doing other things.    Start a receive placing the data into "rcvDat"    Receive characters (placing them into the supplied "rcvDat" buffer) until either the character count reaches "maxRx" or the "match" pattern is found in the received data or the time out "to" expires.    In the UDP mode the "rFlg" allow multiple reads of a UDP pkt, as in reading the header to get the overall len and then re-read the entire packet.    When the receive is complete call the call-back function "callBack", passing a pointer to the received data buffer.    Returns bytes received or an error (negative of errno) or zero if timed out.   

int  io2StrtTx( int handle, int to, pfi_t callBack, int txLen, char* fmt, ... elipsis )
This call and io2StrtRx allow the program to send recieve characters while doing other things.    If txLen is zero transmit the characters indicated by "fmt" expanded any following arguments.    If txLen is not zero it is assumed to be binary data and no expansion is attempted.    The process waits "to" milliseconds for the transmitt to complete and if the time expires returns a zero.    Returns byte count transmitted or an error (negative of errno) or zero if timed out. Start a transmitt of the data in the supplied buffer "txDat"    Receive characters (placing them into the supplied "rcvDat" buffer) until either the character count reaches "maxRx" or the "match" pattern is found in the received data or the time out "to" expires.    When the receive is complete call the call-back function "callBack", passing a pointer to the received data buffer.    Returns bytes received or an error (negative of errno) or zero if timed out.