curl-library
Wait for a response using curl_multi_wait
Date: Mon, 19 Mar 2018 21:04:43 +0000
Hi,
I'm posting this question a second time, although the first time it was
apparently
moderated as spam. Meanwhile somebody asking how to add a header to a
request
got through. It's confusing. I put effort into writing a good question. If
there's something
wrong with my question, I'd like to hear about it. Don't worry about
offending me.
Anyway, here's the original message again:
Using the "multi-single.c" example[1] as a testbed, I notice that after
adding the easy handle and calling curl_multi_perform, the curl_multi_wait
call returns immediately and sets numfds to 0, indicating there is no fd to
wait on.
Question: Isn't there a socket fd to wait on for the connect() and/or the
data?
In the "multi-single.c" example, there is a Sleep() in the main loop. If
the sleep interval is too small then we use too much CPU in going round the
loop. If the interval is too big, we risk reacting too slowly when the
response arrives. A 50ms to 100ms sleep interval is probably Just Right,
but if possible, it would be neater to avoid the Sleep() altogether and
wait (one or more times) for something to happen.
Question: Is it possible?
I tried the sample on Windows 10 with libcurl 7.57.0 built by the MSYS2
project for native Windows (i.e., not relying on Cygwin or MSYS for POSIX
emulation) and on Ubuntu 17.10 using libcurl 7.55.1 from the Ubuntu package
sources (package libcurl4-openssl-dev). Same results on both.
Big thanks to Daniel and everyone who has worked on libcurl. It's a
pleasure to use and the documentation is outstandingly good.
[1] https://curl.haxx.se/libcurl/c/multi-single.html
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2018-03-19