?
Solved

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

Posted on 2003-11-10
3
Medium Priority
?
392 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
[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
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
Dannin earned 120 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 105 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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 …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses
Course of the Month9 days, 13 hours left to enroll

762 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