Possible Duplicate:
How to get an acknowledgement for the client socket from server?
I have implemented a comet message server using netty which keeps connections open for a long time. It works fine, but I fail to detect the following:
Sometimes a client connection has been "unexpectedly" closed, like someone cut the cable. After this happened I can still write to that channel (server side) without getting an error or being able to detect that anything is wrong.
So: How can I detect whether data I sent from my netty server to the client was actually received?
In "old" java.io this is (afaik) done on the socket level. I cannot sense if a connection drops (without keepalives), but in the moment I try to write data to the OutputStream it fails if the connection had dropped meanwhile. However, with netty this does not happen any more and I wonder whether I can still get that information somehow (information = underlying connection has dropped meanwhile, could not deliver data)
Basically: the underlying TCP has run into a timeout because no ACKs were received. How is this surfaced in java.nio / Netty? Currently I can continue to write into a dead connection.