curl req1和rea2对于CURLOPT_CONNECTTIMEOUT + CURLOPT_TIMEOUT问题具有相同的卷曲句柄. [英] curl req1 and rea2 same curl handle for CURLOPT_CONNECTTIMEOUT + CURLOPT_TIMEOUT issue ....

查看:251
本文介绍了curl req1和rea2对于CURLOPT_CONNECTTIMEOUT + CURLOPT_TIMEOUT问题具有相同的卷曲句柄.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

curll_handle =卷曲init()

curll_handle = Curl init()

curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 20 )
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 30);

Request1:(curll_handle)

Request1:(curll_handle)

Curl_easy_perform(curll_handle)
For connection = 20 secs
Chal response request = 30 secs

request2:与上述相同的句柄

request2:same handle used as above

curl_slist_append(headers, "Connection: Close");

Curl_easy_perform(curll_handle)

问题:

Request 1:
    will it use both timeouts(connection and response timeouts) for curl perform?
    what is the total time will take? as per my understand 30 secs(CURLOPT_CONNECTTIMEOUT + CURLOPT_TIMEOUT)

Request 2:
    if we use same request1 curl handle for request2. is it(req2) curl_easy_perform() will d0 both connection and response sequence requestS?
    what the timeout value use for sencond request if use same req1 curl handle? 

推荐答案

请求1:

CURLOPT_TIMEOUT是整个操作的最长时间.它不会花费更多的时间.您知道它将在30秒内完成,无论成功与否.

CURLOPT_TIMEOUT is the maximum time for the entire operation. It will not spend more time. You know it will be done within 30 seconds, successful or not.

CURLOPT_CONNECTTIMEOUT是允许连接阶段"花费的最长时间.如果在20秒内未完成与远程服务器的连接,则传输将返回失败.

CURLOPT_CONNECTTIMEOUT is the longest time you allow the "connection phase" to take. If the connection to the remote server is not done within 20 seconds, the transfer will return failure.

时间完全独立设置.因此,如果连接阶段需要19秒钟,则剩余11秒钟才能完成传输,否则将触发最大超时.

The times are set totally independent of each other. So if the connection phase takes 19 seconds, there is 11 seconds left for the transfer to complete or the maximum timeout will trigger.

请求2:

使用相同的选项,并且粘性的并且在更改之前都是相同的,因此它将具有与请求1完全相同的超时值.

Uses the same options and options are sticky and will be the same until changed, so it will have the exact same timeout values as request 1.

如果连接保留并从请求1重新使用,则CURLOPT_CONNECTTIMEOUT不会触发,因为它已经连接.

If the connection is kept and re-used from request 1, the CURLOPT_CONNECTTIMEOUT won't trigger since it is already connected.

这篇关于curl req1和rea2对于CURLOPT_CONNECTTIMEOUT + CURLOPT_TIMEOUT问题具有相同的卷曲句柄.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆