Network Address Database Functionality
More...
|
file | netdb.h |
| Network address database functionality.
|
|
Network Address Database Functionality
◆ freeaddrinfo()
void freeaddrinfo |
( |
struct addrinfo * | ai | ) |
|
Free an address information structure returned by getaddrinfo().
This function cleans up any memory associated with the specified struct addrinfo, which was returned previously by a call to getaddrinfo().
- Parameters
-
ai | The struct addrinfo to clean up. |
◆ getaddrinfo()
int getaddrinfo |
( |
const char * | nodename, |
|
|
const char * | servname, |
|
|
const struct addrinfo * | hints, |
|
|
struct addrinfo ** | res ) |
Get information about a specified address.
This function translates the name of a host and service into a set of socket addresses and related information to be used in creating a socket. This includes potentially looking up the host information in the network address database (and thus in DNS possibly as well).
- Parameters
-
nodename | The host to look up. |
servname | The service to look up. |
hints | Hints used in aiding lookup. |
res | The resulting address information. |
- Returns
- 0 on success, non-zero error code on failure.
- See also
- getaddrinfo() Error Values
◆ gethostbyname()
struct hostent * gethostbyname |
( |
const char * | name | ) |
|
Look up a host by its name.
This function queries the network address database (possibly recursively) for the network address of the specified hostname. This will first search any local databases before querying remote databases (such as a DNS server) for the host specified.
- Parameters
-
name | The hostname to look up. |
- Returns
- A pointer to a host entry on success or NULL on failure. h_errno is set on failure to indicate the error that occurred.
- Note
- This function is non-reentrant. getaddrinfo() should (in general) be used instead of this function.
◆ gethostbyname2()
struct hostent * gethostbyname2 |
( |
const char * | name, |
|
|
int | af ) |
Look up a host by its name and address family.
This function queries the network address database (possibly recursively) for the network address of the specified hostname. This will first search any local databases before querying remote databases (such as a DNS server) for the host specified.
This function allows you to specify the address family that you wish the returned hostent to contain. This function is a GNU extension and has not been specified by any POSIX specification.
- Parameters
-
name | The hostname to look up. |
af | The address family to use for lookups (AF_INET or AF_INET6). |
- Returns
- A pointer to a host entry on success or NULL on failure. h_errno is set on failure to indicate the error that occurred.
- Note
- This function is non-reentrant. getaddrinfo() should (in general) be used instead of this function.
◆ h_errno