January 23rd, 2013, 05:01 PM
Detecting send failures in a SocketChannel
I have a connected non-blocking SocketChannel. When I call write(), I would like to know whether or not the bytes were successfully transmitted all the way to the server. However, it appears that write() does not work this way, merely queueing up bytes for later internal writing.
Is there any way to detect after the fact whether or not those bytes actually went anywhere, or are just stuck in buffer limbo because connectivity was lost? It does not have to be synchronous, but I need to know one way or the other eventually.
The SocketChannel is concurrently in a Selector for receiving, so I can't take it out of non-blocking mode. I am willing to create a second SocketChannel (or Socket) for communicating in each direction so I can avoid this if necessary, but that doubles the connection establishment overhead so I'm curious if there's a way to do it without this.
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!