For some of my Java NIO connections, when I have a SocketChannel.write(ByteBuffer)
call, it throws an IOException
: "Broken pipe".
What causes a "broken pipe", and, more importantly, is it possible to recover from that state? If it cannot be recovered, it seems this would be a good sign that an irreversible problem has occurred and that I should simply close this socket connection. Is that a reasonable assumption? Is there ever a time when this IOException
would occur while the socket connection is still being properly connected in the first place (rather than a working connection that failed at some point)?
On a side note, is it wise to always call SocketChannel.isConnected()
before attempting a SocketChannel.write()
, and if so, can I also assume that the connection is "broken" and should be closed if both SocketChannel.isConnected()
and SocketChannel.isConnectionPending()
are both false
?
Thanks!