Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2005

Tip: Looking for answers? Try searching our database.

"java.net.BindException: Address already in use: connect" ? ?

Thread view: 
cmk128@hotmail.com - 28 Jul 2005 10:54 GMT
Hi
  My java slcient connect to the server may many time by socket. My
problem is: "socket.close()" doesn't release the local port. After
running "new Socket()" many time, it will get "java.net.BindException:
Address already in use: connect" exception.
  If i specify the local port to be use by "new
Socket("localhoist",18001,InetAddress.getLocalHost(),18002)", it get
the same error, because "socket.close()" doesn't release the port.
thanks
from Peter (cmk128@hotila.com)
Ingo R. Homann - 28 Jul 2005 10:59 GMT
Hi,

> Hi
>    My java slcient connect to the server may many time by socket. My
[quoted text clipped - 6 lines]
> thanks
> from Peter (cmk128@hotila.com)

Sounds to me like the *Socket* will be closed, but of course, the
*ServerSocket* will not be closed as well. The ServerSocket must be
closed explicitely.

Ciao,
Ingo
Gordon Beaton - 28 Jul 2005 20:08 GMT
>    My java slcient connect to the server may many time by socket. My
> problem is: "socket.close()" doesn't release the local port. After
[quoted text clipped - 3 lines]
> Socket("localhoist",18001,InetAddress.getLocalHost(),18002)", it get
> the same error, because "socket.close()" doesn't release the port.

It is normal for the address to remain in use for a few minutes after
closing the Socket.

It is however extremely unusual to care which port number is chosen by
the client. If you don't specify a client port number, the system will
simply choose an available one.

If you really do need to specify the client port number, you can also
use setReuseAddress() and the address will become available again
immediately after you close the Socket.

/gordon

Signature

[  do not email me copies of your followups  ]
g o r d o n + n e w s @  b a l d e r 1 3 . s e



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.