Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > "java.net.BindException: Address already in use: connect" ? ?

Reply
Thread Tools

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

 
 
cmk128@hotmail.com
Guest
Posts: n/a
 
      07-28-2005
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 ((E-Mail Removed))

 
Reply With Quote
 
 
 
 
Ingo R. Homann
Guest
Posts: n/a
 
      07-28-2005
Hi,

http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> 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 ((E-Mail Removed))


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

 
Reply With Quote
 
 
 
 
Gordon Beaton
Guest
Posts: n/a
 
      07-28-2005
On 28 Jul 2005 02:54:18 -0700, (E-Mail Removed) wrote:
> 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.


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

--
[ 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exiting SocketServer: socket.error: (98, 'Address already in use') Magnus Lycka Python 3 05-31-2005 11:15 AM
How do I vlan my already subnetted address? Marshall Lymer Cisco 8 04-24-2005 08:14 PM
'Address already in use' when using socket Bearish Python 2 04-08-2005 09:38 AM
BindException (Address already in use) when connecting to MSSQL Tage V. Madsen Java 5 07-08-2004 06:59 AM
Binding problem - address already in use Aleksander Wodynski C Programming 2 10-01-2003 05:42 PM



Advertisments