Operating System - HP-UX
1833016 Members
2189 Online
110048 Solutions
New Discussion

HP-UX 11.00 Java thread problem

 
SOLVED
Go to solution
Shyam Sundar
Advisor

HP-UX 11.00 Java thread problem

Hi,

I have a problem on my HP-UX 11.00 system, while running a simple java program where the serverSocket.accept() method is waiting to accept connections and in a different thread serversocket.close() is issued. On receiving serversocket.close() the behavior is to throw an exception called "SocketException" and come out of serversocket.accept() waiting method.

Below is the behavior (output) in win2k machine. This output occurs in win2k, winNT, Solaris

C:\jdk1.3\bin>java ThreadTest
ThreadTest-main: Entering main method
ThreadTest-main: Created ServerSocket object
CloseServerSocket: Created CloseServerSocket object
ThreadTest-main: Starting the thread which will close the server socket
ThreadTest-main: Waiting to accept connections
CloseServerSocket-run: Entering run method
CloseServerSocket-run: Trying to close serversocket using close method
Exception :java.net.SocketException: socket closed
ThreadTest-main: Exiting main method
CloseServerSocket-run: Successfully closed serversocket using close method
CloseServerSocket-run: Exiting run method

C:\jdk1.3\bin>


The behavior(output) in HP-UX machine

bash-2.04$ ./java ThreadTest
ThreadTest-main: Entering main method
ThreadTest-main: Created ServerSocket object
CloseServerSocket: Created CloseServerSocket object
ThreadTest-main: Starting the thread which will close the server socket
ThreadTest-main: Waiting to accept connections
CloseServerSocket-run: Entering run method
CloseServerSocket-run: Trying to close serversocket using close method


You could see that it never returned to the bash shell prompt, it actually hangs. It never throws the exception and doesn't comes out of the waiting serverSockte.accept() method. This is not the actual behavior. Java handles all socket type functions through native implementations. All we wanted to know is whether any body has encountered such a problem in HP-UX and whether they have any solutions for it.

Please recommend if any patch could solve thish problem.

The same problem is attached in the doc. along with the swlist output of the system.

Thanks and Regards,
Shyam.
2 REPLIES 2
steven Burgess_2
Honored Contributor

Re: HP-UX 11.00 Java thread problem

Hi

Have a look at the below thread

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x41928cc5e03fd6118fff0090279cd0f9,00.html

Regards

Steve
take your time and think things through
steven Burgess_2
Honored Contributor
Solution

Re: HP-UX 11.00 Java thread problem

Hi

The doc in the thread states

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.


Hope this helps

Steve
take your time and think things through