figaro
figaro

Reputation: 2325

How to set the keepAlive for socket on linux

I'm trying to download a large file using apache FtpCiient and I continually timeout every 2 hours. So, I've set FTPClient.setDataTimeout(readTimeoutInMs); to 3 hours

It works on windows but not on linux.

I saw this in JavaDocs SocketClient.setKeepAlive() -

Sets the SO_KEEPALIVE flag on the currently opened socket. From the Javadocs, the default keepalive time is 2 hours (although this is implementation dependent). It looks as though the Windows WSA sockets implementation allows a specific keepalive value to be set, although this seems not to be the case on other systems.

So, is it true that my readTimeout=3hours doesnt work on linux? What can I do?

Thanks,

Upvotes: 0

Views: 1761

Answers (1)

user207421
user207421

Reputation: 310907

You are confusing several things. Keepalive and read timeouts aren't the same thing.

  • Keepalive is a TCP protocol trick to detect dead connections, e.g. for a Telnet server. It is off by default and when on the default test interval is two hours. For an active FTP connection I doubt that turning it on would make any difference.

  • A read timeout causes the read operation to time out if it hasn't received any data within the timeout period. It applies to each individual read.

  • The FTP data timeout you refer to may be something else again, e.g. a timeout on the total transfer. You would have to look at its documentation to be sure.

Upvotes: 1

Related Questions