I have written a server that performs non-blocking IO using the Java NIO API. I'm seeing a situation whereby occassionally a client application shuts down abruptly (e.g. due to power loss) and the connection is left open on the server-side.
A colleague has encountered the same problem and said he uses heartbeats over the line to detect this kind of thing, but I'm hoping there's an easier way. Has anyone else encountered this problem?
Some additional information: My current server design will cancel a key and close the corresponding channel if it catches an IOException
when attempting a read / write operation. This approach seems to work 99% of the time; I've only seen a handful of situations where the connection appears to be left open.