| 
import requests response = requests.get("http://IPv6test.ntes53.netease.com:8000", stream=True) print response.raw._fp.fp._sock.getpeername() 
 C++ #include <stdio.h> #include <curl/curl.h>  int main(void) {   CURL *curl;   CURLcode res;    curl = curl_easy_init();   if(curl) {     curl_easy_setopt(curl, CURLOPT_URL, "http://IPv6test.ntes53.netease.com:8000");     /* example.com is redirected, so we tell libcurl to follow redirection */      curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);       // curl_easy_setopt(curl, CURL_IPRESOLVE_V6, 1L);  // 使用 IPv6 地址       // curl_easy_setopt(curl, CURL_IPRESOLVE_V4, 1L);  // 使用 IPv4 地址       // curl_easy_setopt(curl, CURL_IPRESOLVE_WHATEVER, 1L);  // 获取系统允许的 IPv4 或者 IPv6 地址      /* Perform the request, res will get the return code */      res = curl_easy_perform(curl);     /* Check for errors */      if(res != CURLE_OK)       fprintf(stderr, "curl_easy_perform() failed: %sn",               curl_easy_strerror(res));      /* always cleanup */      curl_easy_cleanup(curl);   }   return 0; } 
 (编辑:92站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |