On Fri, Jan 16, 2015 at 1:13 PM, Fred Smith fredex@fcshome.stoneham.ma.us wrote:
Normally if you care about knowing if the other end of a connection is gone you could enable keepalives on the socket
That’s also an appropriate fix, especially when the protocol inherently has long periods of idle time, like SSH.
It's been some time since I've dealt with that sort of problem, but My recollection is that even keepalives won't really work, because they occur only every hour or two.
You can control the frequency - and they are sometimes useful to keep otherwise idle connections established through firewalls and NAT gateways that would time out and drop them.
I suppose this kludge would work too: try sending something on that port, and if the connection is broken, it'll error. then you could open a new one.
The problem here is that if the other end isn't reading from the socket - and a camera probably wouldn't - the writes will just queue up until some buffer is filled. And, without keepalives enabled, you still won't get an error on the write.