C-当我查看libcurl代码时,curl connect timeout和最大时间选项值会更改.为什么和什么代表



我正在使用curl命令,并在我注意到以下内容时查看相应的lib卷曲代码:

我的命令:

curl --max-time 1 --connect-timeout 1 -H "User-Agent: ikandaswamy" https://api.github.com/users/ikandaswamy/repos --libcurl newtext

newText

curl_easy_setopt(hnd, CURLOPT_TIMEOUT_MS, 1000L);
curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/7.43.0");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, slist1);
curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
curl_easy_setopt(hnd, CURLOPT_CONNECTTIMEOUT_MS, 1000L);

如果您在上面看到,则curlopt_timeout_ms和curlopt_connecttimeout_ms均为1000(长)。从男人的卷发中,我看到超时时间为几秒钟。为什么转换为1000?

选项名称上的_MS后缀是线索!它代表毫秒,所以一秒钟变成1000毫秒...

顺便说一句,此事实也记录在curlopt_timeout_ms和curlopt_connecttimeout_ms页面中!

--connect-timeout选项接受秒时,它还接受指定为十进制数字的秒数,包括一秒钟(如2.347秒)的分数,并且为了将该精度传递给libcurl,它使用millisecond option版本。

最新更新