Solved

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

Posted on 2003-11-10
3
387 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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to monitor the number of connections/threads being utilized on Tomcat 6.0 8 71
map related example 6 48
Way to decrease size of apk file 9 67
MySQL  on Tomcat 8 46
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
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…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

773 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