Functions



acceptIncoming


public:

DSNetwork * acceptIncoming (void);
Discussion

Accept an incoming connection onto a fresh network connection.

function result
A pointer to the newly created Network connection.

connectToHost


public:

BOOL connectToHost (     char * host,     unsigned short nPort );
Discussion

Connect to the specified hostname. It can process hostnames in the form hostname:port. Note that this function uses gethostbyname to resolve hostnames, and is therefore not threadsafe. You should protect accesses to this function via mutexes, and ensure that gethostbyname is either not used elsewhere or is protected with the same locks.

Parameter Descriptions
host
The name of the host to connect to, can include :port syntax.
nPort
The port to connect to, if no port is specified with the hostname.
function result
TRUE if the connection succeeds, FALSE if it does not.

getChar


public:

BOOL getChar (     char * ch );
Discussion

Retrieves a single incoming character.

Parameter Descriptions
ch
Specifies where to place the character.
function result
Returns TRUE if the operation succeeded, and FALSE if an error occurred.

getChar


public:

BOOL getChar (     unsigned char * ch );
Discussion

Retrieves a single incoming character.

Parameter Descriptions
ch
Specifies where to place the character.
function result
Returns TRUE if the operation succeeded, and FALSE if an error occurred.

getLineFromSocket


public:

BOOLX getLineFromSocket (     char * buffer,     int size );
Discussion

Retrieves an incoming line from the network, if it's there.

Parameter Descriptions
buffer
Specifies the buffer where the line will be copied to.
size
Specifies the maximum size of the buffer.
function result
Returns YES if the operation succeeded, NO if an error occurred, and NOTYET if a complete line isn't available for reading...yet.

getLineFromSocketWait


public:

BOOL getLineFromSocketWait (     char * buffer,     int size );
Discussion

Retrieves an incoming line from the network, and wait till it arrives.

Parameter Descriptions
buffer
Specifies the buffer where the line will be copied to.
size
Specifies the maximum size of the buffer.
function result
Returns TRUE if the operation succeeded, and FALSE if an error occurred.

getSlab


public:

BOOL getSlab (     char * buffer,     int nSize );
Discussion

Retrieves an incoming pile of data from the network, and wait till it arrives.

Parameter Descriptions
buffer
Specifies the buffer where the line will be copied to.
nSize
Specifies the size to be read.
function result
Returns TRUE if the operation succeeded, and FALSE if an error occurred.

getSocket


public:

SOCKET getSocket (void);
Discussion

Retrieves the socket used for low-level operations. Use this with great care. Specifically, only use this only if you need it.

function result
The socket in use.

linger


public:

BOOL linger (void);
Discussion

Switches the network into 'Linger' mode where all remaining data is sent out before a connection is really closed.

function result
Returns TRUE if the operation succeeded, and FALSE if an error occurred.

sendData


public:

BOOL sendData (     const char * szData,     int nSize=-1 );
Discussion

Sends a pile of data into the Network.

Parameter Descriptions
szData
The data to send to the Network.
nSize
The size of the data being sent to the Network; if ommitted, the data will be assumed to be a NULL-terminated string and length determined accordingly.
function result
Returns TRUE if the operation succeeded, and FALSE if an error occurred.

startServer


public:

BOOL startServer (     unsigned short nPort,     unsigned long nIP=0 );
Discussion

Starts the server listening for incoming connections to 1452.

Parameter Descriptions
nPort
The port that the server should listen on.
nIP
The IP address to listen on. If ommitted, will listen on all IP addresses.
function result
Returns TRUE if the operation succeeded, and FALSE if an error occurred.

terminate


public:

BOOL terminate (void);
Discussion

Closes this Network connection.

function result
Returns TRUE if the operation succeeded, and FALSE if an error occurred.

waitForData


public:

BOOL waitForData (     int sec,     int usec );
Discussion

Waits for data to arrive on the connection, either indefinitely or for a period of time, returning TRUE if there is data available to be read.

Parameter Descriptions
sec
The number of seconds to wait for. If this value is negative, wait indefinitely.
usec
The number of microseconds to wait for. This value is ignored if sec is negative.
function result
Returns TRUE if there is data available to be read, FALSE if there is not.

waitForDataEx


public:

BOOLX waitForDataEx (     int sec,     int usec );
Discussion

Waits for data to arrive on the connection, either indefinitely or for a period of time, returning YES if there is data available to be read, NOTYET if there is no data currently, and NO if an error has occurred on the connection.

Parameter Descriptions
sec
The number of seconds to wait for. If this value is negative, wait indefinitely.
usec
The number of microseconds to wait for. This value is ignored if sec is negative.
function result
Returns YES if there is data available to be read, NOTYET if there is no data currently, and NO if an error has occurred on the connection.

(Last Updated 9/24/2004)