Skip to content

Check if system has support for sub-second connect timeouts (CURL_VERSION_ASYNCHDNS) #264

@TysonAndre

Description

@TysonAndre

Related to 4e1c18f. I ask for this because I want to have a 'timeout' of less than a second.

It seems like it should be possible to avoid using signals such as alarm() (via CURLOPT_NOSIGNAL), and to detect if there is an alternative dns resolver (via CURL_VERSION_ASYNCHDNS)

https://curl.haxx.se/libcurl/c/curl_version_info.html

features can have none, one or more bits set, and the currently defined bits are:
...
CURL_VERSION_ASYNCHDNS

libcurl was built with support for asynchronous name lookups, which allows more exact timeouts (even > on Windows) and less blocking when using the multi interface. (added in 7.10.7)

http://stackoverflow.com/questions/25998063/how-can-i-tell-if-the-libcurl-installed-has-asynchronous-dns-enabled also mentions this.

Also, a workaround (when ASYNCDNS is absent) might be to disable timeouts for dns lookup (if the 'connect' time is sub-millisecond), so that the request timeout can be set to less than one second. I'm not sure if that will introduce new bugs, e.g. if DNS is slow/unreliable.

http://www.dsm.fordham.edu/cgi-bin/man-cgi.pl?topic=CURLOPT_NOSIGNAL&ampsect=3

  If this option is set and libcurl has been built with the standard name
  resolver,  timeouts  will not occur while the name resolve takes place.
  Consider building libcurl with the c-ares or threaded resolver backends
  to  enable  asynchronous  DNS  lookups,  to  enable  timeouts  for name
  resolves without the use of signals.

On an unrelated note, is the minimum necessary if the host name is an IPV4 or IPV6 address (e.g. 127.0.0.1, etc.), and HTTP redirects are disabled? (may have to set CURLOPT_NOSIGNAL so that the "lookup" will still avoid timing out)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions