commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel F. Savarese" <...@savarese.org>
Subject Re: The java.net.SocketException: No buffer space available (maximum connections reached?): listen failed Exception
Date Fri, 05 Sep 2008 18:43:22 GMT

[I'm replying from the time-delayed digest, so I apologize in advance
 if someone has already answered this.]

In message <19282416.post@talk.nabble.com>, chitraa writes:
>Without the custom SocketFactory, the connection seems to hang (Hence the
>reason for customising the SocketFactory to set a timeout value). I could
>not replicate the No buffer space available exception.

What's  probably happening is that the connection is timing out, but
the socket isn't being closed.  For example, in your factory method
you have:
  socket.bind(localaddr);
  socket.connect(remoteaddr, clientTimeout);
  return socket;
If the connect times out and throws an exception, the socket should still
be bound.  Therefore, as the application continues to run, it gradually
consumes more and more file descriptors until it runs out.  Try changing
the contents of your factory method to:
  Socket socket = Socket();
  try {
    ...
  } catch(IOException ioe) {
    socket.close();
    throw ioe;
  }
  return socket;

Presumably, you already know whether or not the connections have
been timing out because you must have an exception handler in your main
application code (else the program would abort assuming your main
is declared as throwing IOException).

daniel

o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o o-o-o-o-o-o-o-o-o-o-o-o-o-o
                    Igfip                      o    s a v a r e s e
The strategic alternative for online games(tm).o   software research
            http://www.igfip.com/              o http://www.savarese.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message