cURL / Mailing Lists / curl-users / Single Mail


Re: FTP keep alive connection

From: Daniel Stenberg <>
Date: Mon, 10 Dec 2007 12:35:52 +0100 (CET)

On Thu, 6 Dec 2007, BLANC Gilles wrote:

>> #1 - is keep-alive really *always* a good idea for the tool or shouldn't it
>> be optional with a command line option?

> Well, it doesn't hurt at least.

Doesn't it? After all, TCP doesn't have keep-alive by default for a purpose.
It means you can break the physical connection when there's no traffic and put
the connection back again and nothing happens and everything continues to
happily live on. Keep-alive changes that.

While this most likely is a rather rare scenario these days it is still a
fundamental functionality.

Since nobody spoke up about it so far, I guess people don't feel very strongly
about keep-alive or not.

> So, we could make it optional (at compilation time or with command line
> argument), but as we have seen, it is totally legal to be kicked by a server
> after two hours if you don't use it (well, it is not polite, because it
> should be it that ask if we are alive, not the client to tell, actually),
> and it's only one poor packet lost in gigs of data (because we are not in
> 1989 anymore, data bandwith are huge by now :) ). You tell me ;).

I think I would like it optional to switch it off with a command line flag,
just for the rare circumstances when people don't want this to disturbe.

--no-keep-alive perhaps?

>> #3 - do all systems have SO_KEEPALIVE? I couldn't find any that don't given
>> a quick google.
> Neither do I (with a long google), it is POSIX, and even windows have it ;).
> But former versions seemed to have problem as client, in answering an ACK to
> a probe (which is not our case, because it's us that send a probe for an
> hypothetical strict server).

Yeah, it seems to be available pretty much everywhere!

>> #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...

> Well in the rest of the code, it alters between sizeof (var) and sizeof
> (int) ; once, there is a "sizeof (var) < 0", nasty hacks which is not so
> stupid after all ^^. I don't have a window compiler near me (I'm an healthy
> guy), what would you advise ?

I think we could/should introduce a little #ifdef thing for windows to start
with that typecasts the argument to 'int', but we can also just do that after
we apply and commit your patch.

> I wait for your precisions/decisions ("option or not, that is the
> question"), and the I will post a new patch jus after, if you don't mind :).

Fair enough!

  Commercial curl and libcurl Technical Support:
Received on 2007-12-10