cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: cURL on devices with unstable internet connection

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Sun, 16 Sep 2012 22:11:20 +0200

On Sat, Sep 15, 2012 at 04:19:34PM +0300, Alexander Shashkevych wrote:
>   I'm engineer which is porting webkit browser for car head unit and we are
> using curl as http(s) backend in our project. We have following use case:
> internet access established via mobile phone and it's unstable. In some cases
> phone loses internet connection when curl still  downloading some resources.
> Within 10-20 seconds connection is restored, but curl no longer downloading any
> resources.
>
>  I read FAQ page and there was noted that curl unable to detect situations like
> "unplugged cables", so it looks similar to our use case with broken connection.
> In curl error codes I also not found any code that could be informative about
> abnormal temination of downloading process...
>
>   As I understood there is only one option: use timeouts? Maybe there some
> other solutions are exist to determine such unexpectendly broken connections
> instead of timeouts? Maybe I missed something?

http://curl.haxx.se/docs/faq.html#Why_doesn_t_cURL_return_an_error

There's no way in the general case to tell when an Internet connection
is "down". Is it considered down when someone uplugs an Ethernet cable?
What if the device has a wireless connection too--is it still considered
"down"? What if a bulldozer takes out some fibre on the other end of
town? What about a bulldozer at the other end of the country? It's not a
simple question to answer, so TCP/IP just keeps trying.

In your case, you probably have it easier. You likely only have a single 3G
Internet connection to the rest of the world and have direct access to
the modem to tell when it's up or not. You can use that information if
you want to tear down the interface when the link goes down, which ought
to return a socket error and have libcurl exit with an error code. But,
since the connection might go up again shortly afterward, you're probably
better off playing with the timeouts instead.

>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-09-16