commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chitraleka Appalanaidu" <achitral...@gmail.com>
Subject Re: The java.net.SocketException: No buffer space available (maximum connections reached?): listen failed Exception
Date Mon, 08 Sep 2008 01:00:21 GMT
Hi Daniel,

What you said makes sense. I will add a catch clause to close the socket if
there is an exception. Will post the outcome here.

Thank you.


On Sat, Sep 6, 2008 at 4:43 AM, Daniel F. Savarese <dfs@savarese.org> wrote:

>
> [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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message