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



Hi,

cmk128@xxxxxxxxxxx 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 (cmk128@xxxxxxxxxx)

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

.



Relevant Pages

  • Re: Question with regard to Sockets
    ... > a) Socket is used by the client to initiate ... > listen for incoming connections and using a ServerSocket ... Socket is an end of a connection. ... I know nothing about NTP proxies. ...
    (comp.lang.java.programmer)
  • Re: Question with regard to Sockets
    ... Atirya Yodha wrote: ... > a) Socket is used by the client to initiate ... > listen for incoming connections and using a ServerSocket ... > then how can I make connections to certain web servers (an NTP ...
    (comp.lang.java.programmer)
  • Socket (and Selector) seems to freeze after first data stream
    ... ServerSocketChannel with a Selector for OP_ACCEPT. ... I have a Perl program I'm using to send data to the ServerSocket. ... It does see the first message sent to the socket and receives it properly. ...
    (comp.lang.java.help)
  • Socket communication problem
    ... information it sends an acknowledgement message to the sender. ... public class KKMultiServer { ... ServerSocket serverSocket = null; ... private Socket socket = null; ...
    (comp.lang.java.help)
  • Re: Basic SocketServer & Thread Question
    ... Right now I have one instance of ServerSocket accepting connections from all client IP ... Socket s = serverSocket.bind); ).start; // process stream in a new thread}} ...
    (comp.lang.java.programmer)