cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: check internet connection with curl

From: Gary Maxwell <gmaxwell_at_casabi.com>
Date: Wed, 23 Apr 2008 10:55:43 -0700

Dan Fandrich wrote:
>
> On Wed, Apr 23, 2008 at 04:36:25PM +0200, Meir Yanovich wrote:
> > Hello all
> > is there simple way to check internet connection with curl lib
before
> > starting curl curl_easy_perform ?
>
> Sure, start another connection to the server with another easy handle
and
> if that fails, your connection is down :)
>
Meir,

Even if you perform this "simple" check, there is no guarantee (although
the odds are very good) that the connection will succeed when you issue
your curl_easy_perform. A lot depends on what you are checking: the
physical connection, the hop to your router, or the complete path to the
server. If you want to test all the way to the server by opening a TCP
socket, and the server is down, you will still experience the same
system-dependent delay as you would by trying a curl_easy_perform.

If you would clarify what you are trying to accomplish (my guess is
avoiding a delay when curl_easy_perform fails to connect), we could
offer better suggestions.

-Gary
Received on 2008-04-23