cURL / Mailing Lists / curl-library / Single Mail


Test for connection.

From: Matthew Veenstra <>
Date: Sun, 25 Feb 2007 22:28:28 -0800


Does anyone have a good way to test for a live connection? I
currently use ping and this is of course not the best option.

I am thinking about sending a request and depending on what happens
between the header and the callback functions, abort and return true
or false as appropriate. This is mainly for HTTP and possibly for
FTP does not have header info?

I want this to be synchronous and not asynch as it is basically a one
time call and based upon user interaction in my case so I can handle
any delay a failure may cause.

Here are some questions
- Is the header function called regardless of the server returning
header information?
- Is 3 seconds to short to set for CURLOPT_TIMEOUT. I expect the
user to require a DNS lookup and this not just be a straight IP. It
will be understood that this test is not guaranteed. And appropriate
user feedback may be..."It looks like you are not online. Can you
please verify you are online before continuing."
- If the header is returned does this really mean the server is
alive? Or should I pay attention to the HTTP error if one is there?

Thanks for you thoughts.

Received on 2007-02-26