Solved

ServerSocket.close hangs on HP

Posted on 2002-03-19
10
458 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:pankaj_garg
Comment Utility
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
Comment Utility
I think it is time to close this question
0
 

Author Comment

by:pankaj_garg
Comment Utility
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
Comment Utility
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
Comment Utility
Per recommendation, points refunded and question closed.

Netminder
EE Admin
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

744 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

13 Experts available now in Live!

Get 1:1 Help Now