Functions



acceptIncoming

	public:

DSNetwork * acceptIncoming();

Accept an incoming connection onto a fresh network connection.

Result: A pointer to the newly created Network connection.

connectToHost

	public:

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

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.

Parameters

NameDescription
hostThe name of the host to connect to, can include :port syntax.
nPortThe port to connect to, if no port is specified with the hostname.
Result: TRUE if the connection succeeds, FALSE if it does not.

getChar

	public:

BOOL getChar(char * ch);

Retrieves a single incoming character.

Parameters

NameDescription
chSpecifies where to place the character.
Result: Returns TRUE if the operation succeeded, and FALSE if an error occurred.

getChar

	public:

BOOL getChar(unsigned char * ch);

Retrieves a single incoming character.

Parameters

NameDescription
chSpecifies where to place the character.
Result: Returns TRUE if the operation succeeded, and FALSE if an error occurred.

getLineFromSocket

	public:

BOOLX getLineFromSocket(char * buffer, int size);

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

Parameters

NameDescription
bufferSpecifies the buffer where the line will be copied to.
sizeSpecifies the maximum size of the buffer.
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);

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

Parameters

NameDescription
bufferSpecifies the buffer where the line will be copied to.
sizeSpecifies the maximum size of the buffer.
Result: Returns TRUE if the operation succeeded, and FALSE if an error occurred.

getSlab

	public:

BOOL getSlab(char * buffer,int nSize);

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

Parameters

NameDescription
bufferSpecifies the buffer where the line will be copied to.
nSizeSpecifies the size to be read.
Result: Returns TRUE if the operation succeeded, and FALSE if an error occurred.

getSocket

	public:

SOCKET getSocket();

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

Result: The socket in use.

linger

	public:

BOOL linger();

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

Result: Returns TRUE if the operation succeeded, and FALSE if an error occurred.

sendData

	public:

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

Sends a pile of data into the Network.

Parameters

NameDescription
szDataThe data to send to the Network.
nSizeThe 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.
Result: Returns TRUE if the operation succeeded, and FALSE if an error occurred.

startServer

	public:

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

Starts the server listening for incoming connections to 1452.

Parameters

NameDescription
nPortThe port that the server should listen on.
nIPThe IP address to listen on. If ommitted, will listen on all IP addresses.
Result: Returns TRUE if the operation succeeded, and FALSE if an error occurred.

terminate

	public:

BOOL terminate();

Closes this Network connection.

Result: Returns TRUE if the operation succeeded, and FALSE if an error occurred.

Generated with HeaderDoc - © 2000 Apple Computer, Inc. — (Last Updated 9/29/2003)