On Fri, 30 Aug 2013, 何钦 wrote:
When I use libcurl, I want separate connect timeout and total timeout.
Because when I use keep-alive for connection, I want to set the different
time for connect timeout and transfer timeout. But curl just has
CURLOPT_CONNECTTIMEOUT_MS & CURLOPT_TIMEOUT_MS which is set just for connect
timeout and total timeout.
For example, keep-alive, I want to connect an addr, and it will spend 40ms
in network from client to server. If I set total timeout is 60ms, then I
can't get anything from server, because tcp connect will spend 40ms and the
real data transfer will spend 40ms. But if I can set connect timeout to 60ms
and transfer timeout to 60ms, so I can connect the server and get some real
data, because tcp connect can complete in 60ms, and transfer data can
cpmplete in 60ms too.
Wow, you do have some short timeouts there.
If you allow the connect to take 60ms and you can allow the transfer to take
60ms you therefore implicitly allow the entire operation to take 120ms in a
worst case, right?
So why is a connect-timeout on 60ms and max timeout set to 120ms then so bad?
Sure, when the connect is faster than 60, you allow more than 60 ms for the
transfer but you could still already work with that worst case?
I can't set the CURLOPT_TIMEOUT_MS too long, because I must protect my
client.
How are you protecting your client by cutting off the transfer earlier than
your accepted worst case?
so, I want curl can have an interface for this case to set transfer timeout.
Yeah, normally I would say that most people don't want these timeouts at all
anyway and therefore we wrote up this:
http://curl.haxx.se/docs/faq.html#I_want_a_different_time_out
But with these very very short timeouts within just 100 ms I bet most of those
advice won't suffice. Then we should perhaps consider a new separate "transfer
timeout". But I would really like to hear your answers to my questions above
first.
--
/ daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html