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



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@xxxxxxxxxx)

.



Relevant Pages

  • Re: freeing port - winsock
    ... When I create and destroy many sockets without specifying the local port to bind, It seems that this local port is not free after using the function closesocket. ... It's goal is to create a socket, connect to a remote server on port 80, close the socket and to loop on these actions. ... int host ... SOCKET sock = INVALID_SOCKET; ...
    (comp.programming)
  • Re: listen port 0?
    ... So it is a socket not bound to any local port? ... The printout from lsof is more durky. ... lsof seems more powerful, as pfiles often fails to report fd usage, ...
    (comp.unix.solaris)
  • freeing port - winsock
    ... When I create and destroy many sockets without specifying the local port to bind, It seems that this local port is not free after using the function closesocket. ... It's goal is to create a socket, connect to a remote server on port 80, close the socket and to loop on these actions. ... int host ... SOCKET sock = INVALID_SOCKET; ...
    (comp.programming)
  • Re: How to determine the local port?
    ... > socket was bound to when bind() is not explicitly called. ... > bound to a local port by the kernel. ... Some useful references about C: ...
    (comp.lang.c)
  • Re: NAT Question
    ... :tcp/ip client processes running on the same machine from behind a NAT. ... :process wants to use the same socket local address but connects to ... Or to put it another way, will the two different remote ... NAT should use the same local port for both connections. ...
    (comp.security.firewalls)