PhpRiot
News Archive
PhpRiot Newsletter
Your Email Address:

More information

Setting millisecond-timeouts with curl

Note: This article was originally published at Planet PHP on 13 April 2012.
Planet PHP
I'm currently working on a project where I need to curl to an external server to get some information. If this takes too long, I fall back to a local solution. The timeout for this should be really, really low, so we decided on a 250ms timeout. While testing with this timeout feature, for some reason it *always* used the local fallback. I couldn't figure out why, as when I did a manual curl to the external server, it took 50ms at maximum, way below the timeout value. Turns out it is a problem with libcurl.