<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                [TOC] # 名字與地址轉換 gethostbyname根據給定的主機名,獲取主機信息。 過時,僅用于IPv4,且線程不安全。 ~~~ #include <stdio.h> #include <netdb.h> #include <arpa/inet.h> extern int h_errno; int main(int argc, char *argv[]) { struct hostent *host; char str[128]; host = gethostbyname(argv[1]); printf("%s\n", host->h_name); while (*(host->h_aliases) != NULL) printf("%s\n", *host->h_aliases++); switch (host->h_addrtype) { case AF_INET: while (*(host->h_addr_list) != NULL) printf("%s\n", inet_ntop(AF_INET, (*host->h_addr_list++), str, sizeof(str))); break; default: printf("unknown address type\n"); break; } return 0; } ~~~ # gethostbyaddr函數。 此函數只能獲取域名解析服務器的url和/etc/hosts里登記的IP對應的域名。 ~~~ #include <stdio.h> #include <netdb.h> #include <arpa/inet.h> extern int h_errno; int main(int argc, char *argv[]) { struct hostent *host; char str[128]; struct in_addr addr; inet_pton(AF_INET, argv[1], &addr); host = gethostbyaddr((char *)&addr, 4, AF_INET); printf("%s\n", host->h_name); while (*(host->h_aliases) != NULL) printf("%s\n", *host->h_aliases++); switch (host->h_addrtype) { case AF_INET: while (*(host->h_addr_list) != NULL) printf("%s\n", inet_ntop(AF_INET, (*host->h_addr_list++), str, sizeof(str))); break; default: printf("unknown address type\n"); break; } return 0; } ~~~ # 其他 getservbyname getservbyport 根據服務程序名字或端口號獲取信息。使用頻率不高。 getaddrinfo getnameinfo freeaddrinfo 可同時處理IPv4和IPv6,線程安全的。 # 套接口和地址關聯 getsockname 根據accpet返回的sockfd,得到臨時端口號 getpeername 根據accpet返回的sockfd,得到遠端鏈接的端口號,在exec后可以獲取客戶端信息。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看