cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: socket timeouts

From: <johansen_at_opensolaris.org>
Date: Thu, 1 Jul 2010 09:35:22 -0700

On Wed, Jun 30, 2010 at 07:08:07PM -0400, Ben Kibbey wrote:
> On Thu, Jul 01, 2010 at 12:28:02AM +0200, Daniel Stenberg wrote:
> > On Wed, 30 Jun 2010, Ben Kibbey wrote:
> >
> > >The problem is that the socket is set to non-blocking via
> > >curlx_nonblock() so it doesn't seem possible to determine whether
> > >the transfer timed out or there was no data available.
> >
> > I'm sorry I don't understand what you're trying to accomplish. What
> > is the difference between "transfer timed out" and "there was no
> > data available" ?
>
> I'm trying to get libcurl to return an error when no data has been
> received after some time. Similar I guess to a TCP timeout. My original
> post mentioned the SO_RCVTIMEO setsockopt(2) but this cannot work, if I
> understand the manual page correctly, because libcurl sets the socket to
> non-blocking and the errno would be ambiguous to the non-blocking FD
> (EAGAIN).

Check these options out. They do essentially what you're asking for.
In our application, the low-speed limit is set to 1kb. If the
application doesn't see that much data in 60 seconds, it aborts the
connection. You can tune this according to your needs, though.

http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTLOWSPEEDLIMIT
http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTLOWSPEEDTIME

-j
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-07-01