ygrek / ocurl

OCaml bindings to libcurl
https://ygrek.org/p/ocurl
MIT License
59 stars 32 forks source link

Bind to curl_multi_wait instead of curl_multi_fdset + select #28

Closed nojb closed 6 years ago

nojb commented 6 years ago

Hello,

I am trying to use Curl.Multi.{perform,wait} under Windows. Unfortunately it does not really work because curl_mult_fdset returns -1 in the maxfd argument, signaling that select cannot be used (see doc at https://curl.haxx.se/libcurl/c/curl_multi_fdset.html).

Instead I tried with the function curl_multi_wait which is the recommended way to do select-style polling (see doc at https://curl.haxx.se/libcurl/c/curl_multi_wait.html). This seems to work fine and the C code is simpler.

This PR replaces the use of curl_mult_fdset + select by the simpler use of curl_multi_wait which has the advantage of working under Windows and also (according to the documentation) behaves better with respect to the usual limit of file descriptors of select.

nojb commented 6 years ago

Thanks for the review! I think I addressed both points. I left the default value for timeout_ms set to 1000.

Also, I am not sure if the build system needs to be updated in any way (to test availability of curl_multi_wait or similar).

ygrek commented 6 years ago

re build system - libcurl version check is enough. Thanks for the PR!