Implementation status: partially implemented
void freeaddrinfo(struct addrinfo *ai);
int getaddrinfo(const char *nodename,
const char *servname,
const struct addrinfo *hints,
struct addrinfo **res);
freeaddrinfo() function frees one or more
addrinfo structures returned by
getaddrinfo(), along with any additional storage associated with those structures. If the
ai_next field of the structure is not null, the entire list of structures is freed. The
freeaddrinfo() function supports the freeing of arbitrary sublists of an
addrinfo list originally returned by
getaddrinfo() function translates the name of a service location (for example, a host name) and/or a service name and returns a set of socket addresses and associated information to be used in creating a socket with which to address the specified service.
ai - the
addrinfo structure to be freed,
nodename - the requested service location; either a null pointer (the requested service location is local to the caller) or a pointer to a null-terminated string,
servname - either a null pointer or a pointer to a null-terminated string, a port name or number
hints - a structure containing input values that directs the operation by providing options and by limiting the returned information to a specific socket type, address family, and/or protocol.
res - the result - the pointer to a linked list of
addrinfo structures, each of which specifies a socket address and information for use in creating a socket with which to use that socket address. The list includes at least one
All fields in socket address structures returned by
getaddrinfo() that are not filled in through an explicit argument are set to zero.
freeaddrinfo() function does not return any value.
Upon successful completion,
0. The corresponding error value is returned on failure.
EAI_AGAIN] The name could not be resolved at this time. Future attempts may succeed.
EAI_BADFLAGS] The flags parameter had an invalid value.
EAI_FAIL] A non-recoverable error occurred when attempting to resolve the name.
EAI_FAMILY] The address family was not recognized.
EAI_MEMORY] There was a memory allocation failure when trying to allocate storage for the return value.
EAI_NONAME] The name does not resolve for the supplied parameters.
Neither nodename nor servname were supplied. At least one of these should be supplied.
EAI_SERVICE] The service passed was not recognized for the specified socket type.
EAI_SOCKTYPE] The intended socket type was not recognized.
EAI_SYSTEM] A system error occurred; the error code can be found in
- Delete manifest constants from the function code.
- Implement error handling for the functions