Solved

ServerSocket.close hangs on HP

Posted on 2002-03-19
10
463 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

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

Independent Software Vendors: 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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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 “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This video teaches viewers about errors in exception handling.

623 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