Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Socket closed but still connected

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi !

Again, I'm clueless. I have a java.net.Socket called socket which I want to close (disconnect from the peer). I can close the socket, but I can't disconnect it:

(socket.isClosed()) returns true, but (socket.isConnected) remains true as well. How can I fully cut the connection ? The socket is associated with a java.nio.channels.SocketChannel.

Thanks in advance,
Dennis
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found a solution but I don't understand it.
To close the TCP connection, I had to invoke a select on the selector responsible for reading from the socket:



Any ideas ??
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic