NL_Channel
NL_Channel
nl
1998 12-06
CLASS
NL_Channel - network channel
SYNOPSIS
Class NL_Channel is a generic networking interface. NL provides a confirguation interface along with a few simple operation method with which an application mayopen and use a generic connection.
CONSTRUCTOR
NL_Channel()
Construct a network channel.
MEMBER FUNCTIONS
void AddProtocol(uint32 setting)
Add the desired protocol to supported protocols.
void RemoveProtocol(uint32 setting)
Remove the protocol from supported protocols.
void AddDomain(uint32 setting)
Add the desired domain to the supported domian.
void SetConnectionType(long setting)
Set the connection type, connectionless or connection-oriented.
long SetBlocking(short set)
Set the blocking flag, blocking or non-blocking.
Return TRUE on success otherwise FALSE.
long SetAddress(long location,char *machine_name)
Set address by name. Return TRUE on success otherwise FALSE.
long SetAddress(long location,uint32 machine_number)
Set address by number. Return TRUE on success otherwise FALSE.
long GetAddress(long location,char *machine_name)
Get address by name. Return TRUE on success otherwise FALSE.
uint32 GetAddress(long location)
Get address by number. Return number or 0 for error.
long SetPort(long location,char *service_name)
Set port by name. Return TRUE on success otherwise FALSE.
long SetPort(long location,uint16 port)
Set port by number. Return TRUE on success otherwise FALSE.
long GetPort(long location,char *service_name, long service_name_len)
Get port name for the port specified by location.
The name is returned in the buffer specified by service_name and
service_name_len.
Return TRUE success or FALSE for error.
uint16 GetPort(long location)
Get port by number. Return port on success or 0 for error.
uint16 FindLocalPort(void)
Find out local port (by number) for receiving messages from socket info.
Return port on success or 0 for error.
uint16 Port(uint32 index)
Return the port by index. Return port on success or 0 for error.
SOCKET_HANDLE_T GetIPHandle()
Always return the ip_handle.
NL_HOST_INET_ADDR Address(uint32 index)
Return address by index. Return address on success or 0 for error.
long Open(void)
Open a socket and bind it's name.
If the local port is set to 0 then the system will provide a port number at
this time. This means queries for the local port number are valid after an
Open().
Return TRUE on success otherwise FALSE.
void Close(void)
Close the socket.
long Send(char *buffer, long nbytes)
Send data through socket, the length of the data is given by nbytes.
On success, these functions return the number of bytes sent.
Return values of -1 indicate some locally detected errors.
long Receive(char *buffer, long *nbytes, long msec_timeout)
Recieve data through socket. If a message is too long to fit in the supplied
buffer, excess bytes may be discarded. Return the number of bytes received,
or NL_CHANNEL_ERROR if an error occurred.
The argument msec_timeout specifies how long to wait in microseconds. This
is intended to be used for blocking channels. If msec_timeout is set to
0 then Receive will block indefinitely (for a blocking channel). If no data
is received in the time specified by msec_timeout, NL_CHANNEL_TIMED_OUT is
returned. If a non-blocking channel would have blocked, NL_CHANNEL_WOULD_BLOCK
is returned.
The argument nbytes
is a two way argument. It specifies the number of bytes received and the actual
number received is returned in it. This is useful if some useful data is
returned when this call times out.
long Receive(char *buffer, long nbytes, long msec_timeout)
A version of Receive with a one way nbytes
argument (the count actually read is not returned).
long Receive(char *buffer, long *nbytes)
A two way argument equivalent to Receive(buffer, nbytes, 0).
long Receive(char *buffer, long nbytes)
A one way argument equivalent to Receive(buffer, nbytes, 0).
long Connect(void)
Connect client to server.
If Connect fails the channel should be closed and reopened.
If the channel is already connected TRUE is returned.
Return TRUE on success otherwise FALSE.
NL_Channel *Accept(void)
Accept a connection (server). Return new NL_Channel pointer on success
otherwise NULL. Note that CheckLastError() may be used to determine if
Accept() failed due to it simply being non-blocking.
long IsOpen()
Return TRUE if the channel is open, otherwise return FALSE.
long CheckLastError()
Return the last error. The possible values are:
| NL_CHANNEL_NOERROR |
No error state.
|
| NL_CHANNEL_ERROR |
A true error. Check osdGetLastError() for more detail.
|
| NL_CHANNEL_WOULD_BLOCK |
A non-blocking call returned when it would have blocked if it were a blocking call.
|
| NL_CHANNEL_TIMED_OUT |
A call returned due to a timeout.
|