nlGetRemoteAddr, nlSetRemoteAddr

get or set the remote address of a socket

C Specification

NLboolean nlGetRemoteAddr(NLsocket socket, NLaddress *address)

NLboolean nlSetRemoteAddr(NLsocket socket, const NLaddress *address)



[in]Specifies a socket.


[in/out]Specifies a pointer to the address allocated by the caller.


nlGetRemoteAddr returns the remote address for socket, if socket is connected to a remote address. If socket is not connected and set as NL_RELIABLE or NL_RELIABLE_PACKETS (TCP), or is set to NL_UNRELIABLE (UDP) and nlRead has never been called, then address will correspond to the default NIC IP address. If socket is not connected, is set as NL_UNRELIABLE (UDP), and nlRead has received a packet, then address will correspond to the remote address of the last packet received. If nlGetRemoteAddr was successful address.valid will be set to NL_TRUE, otherwise it will be set to NL_FALSE.

nlSetRemoteAddr sets the remote address on an unconnected UDP socket. Since address is updated everytime nlRead is called, nlSetRemoteAddr should be called before each nlWrite.

Return values

NL_TRUE if no error occurs, otherwise NL_FALSE, and the specific error code can be retrieved by calling nlGetError

Error codes

NL_INVALID_SOCKET : The socket is not valid.
NL_NULL_POINTER : A NULL pointer was passed to this function.
NL_SYSTEM_ERROR : A system Socket error has ocurred. The system error can be retrieved by calling nlGetSystemError.

See also


Back to the HawkNL index page

Go directly to the main HawkNL page at Hawk Software

© 2000-2002 Phil Frisbie.

Valid XHTML 1.0!