struct addrinfo / getaddrinfo()

       #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;
           };

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值