PSI sics-cvs-psi-2006

This commit is contained in:
2006-05-08 02:00:00 +00:00
committed by Douglas Clowes
parent ae77364de2
commit 6e926b813f
388 changed files with 445529 additions and 14109 deletions

View File

@@ -17,6 +17,8 @@
Mark Koennecke, October 2001
Changed all timeout units from microseconds to milliseconds
Markus Zolliker August 2004
----------------------------------------------------------------------------*/
#ifndef NNNET
#define NNNET
@@ -44,18 +46,30 @@
else a valid mkChannel structure for the port
*/
mkChannel *NETAccept(mkChannel *self, int timeout);
mkChannel *NETAccept(mkChannel *self, long timeout);
/* tries to accept a new connection on the Channel self
until timeout. If a connection can be built a new mkChannel
structure is returned, else NULL. With a negative value or 0 for
timeout this function blocks for an accept.
*/
*/
mkChannel *NETConnect(char *name, int port);
/* tries to open a client connection to the server specified by name
and port. Returns NULL on failure, a struct else
*/
mkChannel *NETConnectWithFlags(char *name, int port, int flags);
/* the same as NETConnect, but with flags:
if (flags & 1): do not block on connect (use NETConnectFinished
to check success)
if (flags & 2): wait 1000 ms after last close (workaround for
a bug in Lantronix terminal server
*/
int NETConnectFinished(mkChannel *self);
/* returns 0 if in progress, 1 on success, a negative value on error
*/
int NETInfo(mkChannel *self, char *pComposter, int iBufLen);
/* Once a socket is connected it is possible to figure out
which host the connection came from. Maximum iBufLen characters
@@ -69,28 +83,32 @@
false otherwise.
*/
long NETRead(mkChannel *self, char *buffer, long lLen, int timeout);
long NETRead(mkChannel *self, char *buffer, long lLen, long timeout);
/* reads data from socket self into buffer with max length lLen
waits maximum timeout for data. Returns -1 on error, 0 on no
data, and else the length of the data read. With a negative value
or 0 for timeout this function blocks for the read.
or 0 for timeout this function blocks for the read.
*/
int NETAvailable(mkChannel *self, int timeout);
/*
returns 1 if data is pending on the port, 0 if none is
int NETAvailable(mkChannel *self, long timeout);
/* returns 1 if data is pending on the port, 0 if none is
pending.
*/
int NETReadTillTerm(mkChannel *self, int timeout,
int NETReadTillTerm(mkChannel *self, long timeout,
char *pTerm, char *pBuffer, int iBufLen);
/*
reads data until one of the terminators defined in pTerm has
been found. The data is copied into the buffer pBuffer. A
maximum length of iBufLen characters is observed. The timeout
parameter defines a maximum time to wait for a terminator to
appear. NETReadTillTerm returns 1 on success, 0 on a timeout,
appear. NETReadTillTerm returns the number of characters read
(including terminator) on success, 0 on a timeout,
and a negative value if a network error occurred. Beware that
this may not work correctly if the wrong terminator is given.
The last one is really needed.
In the new version, timeout is in MILLIseconds (10 -3 sec).
However, the accuracy is machine dependent (for Linux 10 ms, for Tru64 1 ms)
If no terminator is given, the routine waits for iBufLen characters
or timeout.
*/
/* ********************* KILLING FIELD ******************************** */
int NETClosePort(mkChannel *self);