cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: FTP keep alive connection

From: BLANC Gilles <gblanc_at_linagora.com>
Date: Wed, 5 Dec 2007 15:53:52 +0100

On 8 Nov 2007, Daniel Stenberg wrote:
> On Thu, 8 Nov 2007, Loiseleur Michel wrote:
>>> You should be able to accomplish the same thing without touching libcurl
>>> code at all using the CURLOPT_SOCKOPTFUNCTION callback. That makes it
>>> 100% nonintrusive.
>>>
>> Since I use the curl binary client, and not the libcurl, I do not really
>> understand how I can get a feature and being 100% nonintrusive.
>>
>> Would you please explain your idea with more in detail ?
 
> The curl app could be made to use the CURLOPT_SOCKOPTFUNCTION callback, and
> within that the SO_KEEPALIVE option can be set. There's no need for patching
> the library for this.

    Hi,

I have indeed added a call to "my_setopt" with the CURLOPT_SOCKOPTFUNCTION tag
(after all the "my_setopt " already in the code), referring to a new function
called "set_so_keepalive" (inserted just before), which just do the right
setsockopt (for the CURLSOCKTYPE_IPCXN purpose argument, because the doc tell
us that the library may support other options for this callback later). It
returns 1 if it fails, so as the connection is closed according to the
library code and doc (maybe too violent ?).

It is the first use of CURLOPT_SOCKOPTFUNCTION in the whole code,
apparently :) (which is finally called in lib/connect.c, line 726, useful at
last !). Here is the patch, only applied to src/main.c (and no longer the
lib, so that this message is no longer in the right place I think...). Hope
it will be integrated in the mainstream line :) (or at least very useful for
weird firewalled guys).
 
    Regards,

-- 
Gilles Blanc - gblanc_at_linagora.com
Groupe LINAGORA - http://www.linagora.com
Tél.: +33(0)1 58 18 68 28 - Fax : +33(0)1 58 18 68 29

Received on 2007-12-05