KallistiOS  ##version##
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Data Structures | Macros | Functions | Variables
netdb.h File Reference

Network address database functionality. More...

#include <sys/cdefs.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <inttypes.h>

Go to the source code of this file.

Data Structures

struct  hostent
 Network host entry. More...
 
struct  addrinfo
 Network address information structure. More...
 

Macros

#define h_addr   h_addr_list[0]
 Primary network address. More...
 
#define HOST_NOT_FOUND   1
 Hostname not found. More...
 
#define TRY_AGAIN   2
 Try the request again. More...
 
#define NO_RECOVERY   3
 A non-recoverable error. More...
 
#define NO_DATA   4
 Host found, but no data. More...
 
#define EAI_AGAIN   1
 Try the request again. More...
 
#define EAI_BADFLAGS   2
 Invalid hint flags. More...
 
#define EAI_FAIL   3
 A non-recoverable error. More...
 
#define EAI_FAMILY   4
 Invalid address family. More...
 
#define EAI_MEMORY   5
 Memory allocation error. More...
 
#define EAI_NONAME   6
 Hostname not found. More...
 
#define EAI_SERVICE   7
 Invalid service value. More...
 
#define EAI_SOCKTYPE   8
 Invalid socket type. More...
 
#define EAI_SYSTEM   9
 System error, check errno. More...
 
#define EAI_OVERFLOW   10
 Argument buffer overflow. More...
 
#define AI_PASSIVE   0x00000001
 Address intended for bind(). More...
 
#define AI_CANONNAME   0x00000002
 Request canonical name. More...
 
#define AI_NUMERICHOST   0x00000004
 Inhibit host resolution. More...
 
#define AI_NUMERICSERV   0x00000008
 Inhibit service resolution. More...
 
#define AI_V4MAPPED   0x00000010
 Return v4-mapped IPv6 addrs. More...
 
#define AI_ALL   0x00000020
 Query for both IPv4 and IPv6. More...
 
#define AI_ADDRCONFIG   0x00000040
 Only query for IPv4/IPv6 addrs the system has a valid addr. More...
 

Functions

void freeaddrinfo (struct addrinfo *ai)
 Free an address information structure returned by getaddrinfo(). More...
 
int getaddrinfo (const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res)
 Get information about a specified addresss. More...
 
struct hostentgethostbyname (const char *name)
 Look up a host by its name. More...
 
struct hostentgethostbyname2 (const char *name, int af)
 Look up a host by its name and address family. More...
 

Variables

int h_errno
 Error value for gethostbyname(). More...
 

Detailed Description

Network address database functionality.

This file contains functions related to network address lookups, usually performed through DNS.

Author
Lawrence Sebald

Macro Definition Documentation

#define h_addr   h_addr_list[0]

Primary network address.

Function Documentation

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
aiThe struct addrinfo to clean up.
int getaddrinfo ( const char *  nodename,
const char *  servname,
const struct addrinfo hints,
struct addrinfo **  res 
)

Get information about a specified addresss.

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
nodenameThe host to look up.
servnameThe service to look up.
hintsHints used in aiding lookup.
resThe resulting address information.
Returns
0 on success, non-zero error code on failure.
See also
Errors for the getaddrinfo() function
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
nameThe 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.
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
nameThe hostname to look up.
afThe 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.

Variable Documentation

int h_errno