This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Distributed Java and the fly likes Socket closed but still connected Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Socket closed but still connected" Watch "Socket closed but still connected" New topic
Author

Socket closed but still connected

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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

Joined: Nov 22, 2008
Posts: 18944
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 ??
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Socket closed but still connected
 
Similar Threads
Reconnecting Sockets
SocketChannel And Socket Shutdown/recycle
Problem with echo server and client.
No data send trough socket
Saying "goodbye" correctly with sockets