File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Sockets and Internet Protocols and the fly likes Nio : How to close a socket channel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Nio : How to close a socket channel" Watch "Nio : How to close a socket channel" New topic

Nio : How to close a socket channel

Kris Adams

Joined: Jul 02, 2004
Posts: 17
I am using socket channel for communication (created as shown below). Each time i use it, i am closing by invoking socketChannel.close(). But this doesnt seem to be closing the tcp connection.

SocketChannel socketChannel =;
socketChannel.connect(new InetSocketAddress(ip, port));

Can someone sugg the right way to terminate the connection.
J Kneeland
Ranch Hand

Joined: Aug 15, 2004
Posts: 31
Joe Ess

Joined: Oct 29, 2001
Posts: 9168

This question belongs in the Sockets and Internet Protocols forum.

[How To Ask Questions On JavaRanch]
I agree. Here's the link:
subject: Nio : How to close a socket channel
It's not a secret anymore!