Re: FTP keep alive connection
Date: Thu, 6 Dec 2007 13:05:09 +0100 (CET)
On Wed, 5 Dec 2007, BLANC Gilles wrote:
(Cc'ing this reply over to the curl-users list since now we're talking changes
to the tool, not the lib, let's continue this thread there!)
> 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).
A few remarks about the patch:
#1 - is keep-alive really *always* a good idea for the tool or shouldn't it be
optional with a command line option?
#2 - the funny ascii graphics in the outputs don't belong there as nothing
else in curl do that. It seems using warnf() is the better approach for
warnings-style output in the tool.
#3 - do all systems have SO_KEEPALIVE? I couldn't find any that don't given a
#4 - A minor nuisance is that setsockopt() on POSIX takes a socklen_t type in
its last argument while for example winsock takes (and I believe some
pre-POSIX unixes do too) an 'int', so using sizeof() like that will cause
a warning on some compilers...
#5 - your not using 'clientp' will cause compiler warnings, but I figure
that it'll become used if you fix #2 since that needs a config pointer...
#6 - the function set_so_keepalive() should be made static
-- Commercial curl and libcurl Technical Support: http://haxx.se/curl.htmlReceived on 2007-12-06