Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ServerSocketChannel.socket() is still bound after close()

Posted on 2004-08-26
5
Medium Priority
?
1,216 Views
Last Modified: 2012-08-13
Hi all,
I recoded my server program to use java.nio and it works fine.
When I try to close socket:
  serverSocket.socket().close();
  boolean b1 = serverSocket.socket().isBound();
  boolean b2 = serverSocket.socket().isClosed();
and check values, b1 is true and b2 is true.
When I run netstat I see that state od port is "LISTENNING"
While I was using "old" IO, closing socket did excatly what I expected (netstat did not list port as Listenning).

How can I "unbind" socket without shuting down JVM?

Zdenko
0
Comment
Question by:szden
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 11901637
See how long that situation persists - you may find what you expect after a short time
0
 
LVL 35

Accepted Solution

by:
TimYates earned 500 total points
ID: 11901639
I had a quick look at the source for serversocket, and I don't think you can...
0
 

Expert Comment

by:dsj_shock
ID: 11901842
Try closing the channel it self instead of its associated socket, like:

ServerSocketChannel serverSocket ...;
serverSocket.close();

I think that will help, because closing the socket only has to be done when using the old I/O-package. ServerSocketChannel's besides being closed also have to be decoupled from the Selector, which will not be done, when using the code:

serverSocket.socket().close();
0

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question