?
Solved

ServerSocket.close hangs on HP

Posted on 2002-03-19
10
Medium Priority
?
467 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
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

719 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