cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: FTP keep alive connection

From: Jamie Lokier <jamie_at_shareable.org>
Date: Wed, 7 Nov 2007 18:31:09 +0000

Dan Fandrich wrote:
> On Tue, Nov 06, 2007 at 08:33:08PM +0000, Jamie Lokier wrote:
> > FTP servers implement a timeout by closing the connection when they
> > haven't received a command for some time. (Though some of them seem
> > to timeout even if they have, strangely.)
> >
> > SO_KEEPALIVE by the client won't change that. The server still won't
> > receive anything that's noticed by the application, and it will still
> > close the connection after that time.
>
> But hopefully, the server won't close the control connection while in the
> middle of sending a file. That's the situation where this is needed most--
> a NAT closing the control connection while a file in being transferred.

Very good point, I didn't think of NAT.

SO_KEEPALIVE defaults to every 2 hours, which is a bit long to keep
open a NAT connection in my experience.

You can reduce the time on some OSes using some more socket options:

    TCP_KEEPCNT, TCP_KEEPIDLE, TCP_KEEPINTVL.

This is much better then sending data, for keeping a NAT open.

Sending repeated NOOP commands would get stuck when the buffers and
windows filled, so even if libcurl handled the responses properly, it
would not keep a NAT open for a very long time, when used with a
server that ignores its control input while transferring data.

-- Jamie
Received on 2007-11-08