Today most servers have shorter timeouts, mostly as a defense against denial of service attacks. But it's often the HTTP server, not the TCP level, that times out first.
[1] https://blogs.technet.microsoft.com/nettracer/2010/06/03/thi...
Today most servers have shorter timeouts, mostly as a defense against denial of service attacks. But it's often the HTTP server, not the TCP level, that times out first.
[1] https://blogs.technet.microsoft.com/nettracer/2010/06/03/thi...
This is not true, in general. I think you're describing connections which have TCP KeepAlive enabled on them.
[1] https://tools.ietf.org/html/rfc0793 [2] https://tools.ietf.org/html/rfc5482
> The TCP user timeout controls how long transmitted data may remain > unacknowledged before a connection is forcefully closed.
As I understand it, this only applies if there is data outstanding. In the puzzler, there was no data outstanding. You're right that if there had been, the side with data outstanding would eventually notice the problem and terminate the connection. The default timeout on most systems I've seen is 5-8 minutes.
By contrast, the previous article you linked was about KeepAlive, which will always eventually detect this condition, but by default usually not for at least two hours.
All TCP keep alive does is send a packet every so often, which is actually something which is rarely actually set.
e.g. my home router has a connection timeout of 24 hours.
The socket should be marked ready for reading, but when you try to read you'll get zero bytes back: Something in your framework may not realize that -- truss/strace the process and I'd guess you'll see a 0 byte read followed by not closing it; alternatively you may not be polling the socket for read availability?
Some things would change if you intended for the socket to be half closed, but I don't think you do?
If you need to know sooner that your data isn't going to be sent, it's pretty trivial to set up a short timeout that overrides the system defaults.
[1] https://www.freebsd.org/cgi/man.cgi?query=setsockopt&sektion...
Setting those options isn't much different from setting a timeout in your poll() call.