Operating System - HP-UX
1832690 Members
2782 Online
110043 Solutions
New Discussion

Java - Sever Socket Close Fails

 
SOLVED
Go to solution
Ajay Bansal_1
Occasional Contributor

Java - Sever Socket Close Fails

Hi All

I'm having an application which is using close() method of java.net.SeverSocket class. The call to close()
method just hangs on HP machine, while the same application works perfectly fine on Solaris machine.

If I write a small program to test close() method call on HP, it works fine. But this application just
hangs at close() method call. I have put print's before and after this call. The first print comes but
the second doesn't.

System.out.println("X1");
serverSocket.close() // hangs at this point
System.out.println("X2");

Can anybody give me some pointer on how I can nail down the exact problem in my application.

I have applied all the patches listed at "http://www.hp.com/products1/unix/java/infolibrary/patches.html". Also it is written in release notes of jdk 1.3.1.02 for HP (ftp://ftp.hp.com/pub/gsy/sdk_13102os11.depot) that this issues has been resolved. But I am still facing the same!!!!!!!!

What is the solution for the same?

Regards
Ajay Bansal
1 REPLY 1
oiram
Regular Advisor
Solution

Re: Java - Sever Socket Close Fails

Hi,
Is the socket waiting for any access

-------
closing a socket when accept or read is pending

If you have one thread performing an accept or read on a socket, and try to close the socket to clean up resources, the default behavior is for the close() to block until the accept or read call completes. If you want to change this behavior, you should use the following Java command line option:


-XdoCloseWithReadPending
This option allows one thread to close a socket when there is an outstanding accept or read pending on the same socket from another thread.

With the -XdoCloseWithReadPending option, the socket close() call closes the socket and, in the context of the thread with the pending read or accept, a SocketException with the message "Socket closed" is thrown.

------------------------------------

http://www.hp.com/products1/unix/java/java2/sdkrte1_3/infolibrary/sdk_rnotes_1-3-1-02.html

I hope this help.