#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
int getaddrinfo(const char *node, const char *service,
const struct addrinfo *hints,
struct addrinfo **res);
void freeaddrinfo(struct addrinfo *res);
const char *gai_strerror(int errcode);
// Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
// getaddrinfo(), freeaddrinfo(), gai_strerror():
// Since glibc 2.22: _POSIX_C_SOURCE >= 200112L
// Glibc 2.21 and earlier: _POSIX_C_SOURCE
//DESCRIPTION
// Given node and service, which identify an Internet host and a
// service, getaddrinfo() returns one or more addrinfo structures, each
// of which contains an Internet address that can be specified in a call
// to bind(2) or connect(2). The getaddrinfo() function combines the
// functionality provided by the gethostbyname(3) and getservbyname(3)
// functions into a single interface, but unlike the latter functions,
// getaddrinfo() is reentrant and allows programs to eliminate
// IPv4-versus-IPv6 dependencies.
// The addrinfo structure used by getaddrinfo() contains the following
// fields:
struct addrinfo {
int ai_flags;
int ai_family;
int ai_socktype;
int ai_protocol;
socklen_t ai_addrlen;
struct sockaddr *ai_addr;
char *ai_canonname;
struct addrinfo *ai_next;
};
struct addrinfo / getaddrinfo()
最新推荐文章于 2022-07-29 17:05:20 发布