Solved

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

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

760 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

23 Experts available now in Live!

Get 1:1 Help Now