Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ServerSocket.close hangs on HP

Posted on 2002-03-19
10
Medium Priority
?
469 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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
 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
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.
Suggested Courses

972 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