Solved

java.net.BindException: Address in use: bind error

Posted on 2003-11-10
3
386 Views
Last Modified: 2006-11-17
Hi,

I get the port in use error above when implementing this line:
ServerSocket ss = new ServerSocket( portnumber);

Most likely the reason I get it because I run my program over and over as I am testing this.

I know I can restart the server or my machine to resolve this port in use, but is there a way to programmatically resolve this issue?  Thanks.

0
Comment
Question by:Mero
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
Dannin earned 40 total points
ID: 9717481
have u tried setting ss to null after your done with it before the program ends. And make sure ur closed any Socket's u may have created in the process=)
0
 
LVL 92

Assisted Solution

by:objects
objects earned 35 total points
ID: 9718407
ss has to be closed before you can open another ServerSocket on the same port.

You could open a different port each time you started the server.
0
 
LVL 92

Expert Comment

by:objects
ID: 9734971
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
The viewer will learn how to implement Singleton Design Pattern in Java.

919 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now