Solved

ServerSocket.close hangs on HP

Posted on 2002-03-19
10
459 Views
Last Modified: 2007-12-19
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.

Thanks,
Pankaj
0
Comment
Question by:pankaj_garg
10 Comments
 
LVL 9

Expert Comment

by:Venci75
ID: 6881977
I had the same problem. It is a java problem. I can suggest the following workaround:

ServerSocket ss = new ServerSocket(port);
ss.accept();

to close ss use this code in a different thread:

try {
  // first force the accept() to return
  new Socket("localhost", port);
} catch(IOException e) {
}
ss.close();
0
 
LVL 1

Expert Comment

by:BaneBane
ID: 6882127
Hi,

I think this problem was fixed in HPs SDK release version 1.2.2.08


look at: http://www.hp.com/products1/unix/java/java2/sdkrte/infolibrary/sdk12208/problem_fixes_issues.html

and specifically at:
HP SR 8606173925 JAGad43178 Socket close hangs if there's a write outstanding on the socket  

Hope this helps.
0
 

Author Comment

by:pankaj_garg
ID: 6882265
Hi,
  I'm already using Java 1.3 which ships SDK 1.3 along with it. Do you think I need to install some patch for this problem.

Thanks,
Pankaj
0
 

Author Comment

by:pankaj_garg
ID: 6898511
Hi Venci,
    Your fix is working and my application does come out.
Were you also facing this problem on Java 1.3 on HP. The above mentioned link by BaneBane suggests that this prblem had been fixed in Java 1.3

http://www.hp.com/products1/unix/java/java2/sdkrte/infolibrary/sdk12208/problem_fixes_issues.html


Thanks,
Pankaj
0
 
LVL 9

Expert Comment

by:Venci75
ID: 6898661
Actually - it is a workaround. I had this problem on HP with java 1.2 (not sure about 1.3). But I had similar problem on Windows with java 1.2
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:pankaj_garg
ID: 6898744
Hi BaneBane,
 I'm already using Java 1.3 which ships SDK 1.3 along with it. I have also installed the patches required for Java 1.3 on HP 11i. Is there a way I can report the same to Java people.

Venci's workaround solution seem to be working for me.

0
 
LVL 9

Expert Comment

by:Venci75
ID: 6901992
I think it is time to close this question
0
 

Author Comment

by:pankaj_garg
ID: 6909800
Hi,
   I have found the solution to this problem. We need to use the following -XdoCloseWithReadPending
 
For Details goto this page
http://www.hp.com/products1/unix/java/java2/sdkrte1_3/infolibrary/sdk_rnotes_1-3-1-02.html
**********************************************************************
The HP-UX Developer's Kit for Java֨JDK) 1.1.8 releases for HP-UX 11.00 and for HP-UX 10.20 provide the solutions necessary to develop or deploy performance-enhanced Java applications on HP 9000 Enterprise Servers, HP 9000 Workstations, and HP Visualize Workstations.

Beginning with version 1.18.00 we included HP's new JIT compiler, which provides a
substantial boost at runtime. Beginning with version 1.18.00, we also included a number of new command line options which are summarized below (and further documented in the Documentation section):

The -doCloseWithReadPending option allows you to close() a socket when there is an
outstanding read pending on another thread.

New Option: -doCloseWithReadPending

The java, java_g, jre, and jre_g command line option -doCloseWithReadPending allows you to close() a socket when there is an outstanding read pending on another thread. Without this option, if close() is called on a socket which already has an outstanding blocked call on another thread, the close would block until the other call returned. With the option, close completes and the other thread takes a SocketException with the message "Socket closed".

I beleive it was introduced due tovorrect timing issues / bugs wrt complier , threads etc ...


-pankaj
0
 
LVL 9

Expert Comment

by:Venci75
ID: 7901239
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
PAQ'd and pts refunded
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Venci75
EE Cleanup Volunteer
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 7962365
Per recommendation, points refunded and question closed.

Netminder
EE Admin
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now