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 <[EMAIL PROTECTED]> wrote:
>
> [I'm replying from the time-delayed digest, so I apologize in advance
> if someone has already answered this.]
>
> In message <[EMAIL PROTECTED]>, 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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>