● sockaddr
#include
struct sockaddr
{
sa_family_t sa_family;
char sa_data[14];
};
● in_addr_t
#include
/* Internet address. */
typedef uint32_t in_addr_t;
struct in_addr
{
in_addr_t s_addr;
};
● in_port_t
#include
/* Type to represent a port. */
typedef uint16_t in_port_t;
● sockaddr_in
#include
struct sockaddr_in
{
sa_family_t sin_family;
in_port_t sin_port;
struct in_addr sin_addr;
unsigned char sin_zero[sizeof (struct sockaddr) -
(sizeof (unsigned short int)) -
sizeof (in_port_t) -
sizeof (struct in_addr)];
};
● addrinfo, servent, protoent, netent, hostent
/* Structure to contain information about address of a service provider. */
struct addrinfo
{
int ai_flags;/* Input flags. */
int ai_family;/* Protocol family for socket. */
int ai_socktype;/* Socket type. */
int ai_protocol;/* Protocol for socket. */
socklen_t ai_addrlen;/* Length of socket address. */
struct sockaddr *ai_addr;/* Socket address for socket. */
char *ai_canonname;/* Canonical name for service location. */
struct addrinfo *ai_next;/* Pointer to next in list. */
};
/* Description of data base entry for a single service. */
struct servent
{
char *s_name;/* Official service name. */
char **s_aliases;/* Alias list. */
int s_port;/* Port number. */
char *s_proto;/* Protocol to use. */
};
/* Description of data base entry for a single service. */
struct protoent
{
char *p_name;/* Official protocol name. */
char **p_aliases;/* Alias list. */
int p_proto;/* Protocol number. */
};
/* Description of data base entry for a single network. NOTE: here a
poor assumption is made. The network number is expected to fit
into an unsigned long int variable. */
struct netent
{
char *n_name;/* Official name of network. */
char **n_aliases;/* Alias list. */
int n_addrtype;/* Net address type. */
uint32_t n_net;/* Network number. */
};
/* Description of data base entry for a single host. */
struct hostent
{
char *h_name;/* Official name of host. */
char **h_aliases;/* Alias list. */
int h_addrtype;/* Host address type. */
int h_length;/* Length of address. */
char **h_addr_list;/* List of addresses from name server. */
#if defined __USE_MISC || defined __USE_GNU
# defineh_addrh_addr_list[0] /* Address, for backward compatibility.*/
#endif
};