nlAddrToString, nlStringToAddr

convert an address to a string, or a string to an address

C Specification

NLchar* nlAddrToString(const NLaddress *address, NLchar *string)

NLboolean nlStringToAddr(const NLchar *string, NLaddress *address);

Parameters

address

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

string

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

Description

nlAddrToString converts an address to a string in the format xxx.xxx.xxx.xxx:xxxxx, stores it into the caller supplied string, and returns a pointer to string. string must be allocated NL_MAX_STRING_LENGTH memory to store the address string. If the port number is '0', then the returned string does not have the port number or the trailing ':'.

nlStringToAddr converts a string in the format xxx.xxx.xxx.xxx:xxxxx to an address. If no port number is not supplied, then the port number will be set to 0. If the string was converted successfully, then address.valid will be set to NL_TRUE, otherwise it will be set to NL_FALSE.

Return values

If no error occurs, nlAddrToString returns a pointer to string, otherwise a value of NULL is returned, and the specific error code can be retrieved by calling nlGetError

If no error occurs, nlStringToAddr returns NL_TRUE, otherwise NL_FALSE is returned and the specific error code can be retrieved by calling nlGetError

Error codes

NL_NULL_POINTER : A NULL pointer was passed to this function.
NL_BAD_ADDR : String does not have the proper xxx.xxx.xxx.xxx:xxxxx format.

See also

nlGetAllLocalAddr,
nlGetLocalAddr,
nlGetRemoteAddr


Back to the HawkNL index page


Go directly to the main HawkNL page at Hawk Software

© 2000-2002 Phil Frisbie.

Valid XHTML 1.0!