Operating System - HP-UX
1753596 Members
6459 Online
108796 Solutions
New Discussion юеВ

Re: Java 2 HP-UX java.net.PlainSocketImpl.socketClose() hang

 
David Grigglestone
Occasional Contributor

Java 2 HP-UX java.net.PlainSocketImpl.socketClose() hang

If there is a more suitable forum for this question could somone please direct me (I could not find one from the HP site).

Anyway the issue is on HP-UX (iirespective of jdk1.2.2 or 1.3) a call to java.net.Socket.close() [which results in the call to java.net.PlainSocketImpl.socketClose()] seems to hang (at least for a period). This certainly does not happen on any of the other Java platforms I have tested.

Has anyone seen anything similar and/or know of a workaround ?

thanks, David
3 REPLIES 3
David Grigglestone
Occasional Contributor

Re: Java 2 HP-UX java.net.PlainSocketImpl.socketClose() hang

Here is some sample code (on other platfoms e.g. Solaris, win32, etc. the code works in the expected fashion .. on HP-UX the close() simply hangs forever).

import java.io.*;
import java.net.*;

public class scr1443
{
public static void main(String[] args)
{
new scr1443();
}

scr1443()
{
try
{
ServerSocket acceptor = new ServerSocket(7777);
new SocketCloser(acceptor).start();
while (true)
{
System.out.println("scr1443 .. accepting");
acceptor.accept();
}
} catch(Exception e) { e.printStackTrace(); }
}

class SocketCloser
extends Thread
{
ServerSocket acceptor;

SocketCloser(ServerSocket acceptor)
{
this.acceptor = acceptor;
}

public void run()
{
try { Thread.sleep(5000); } catch(InterruptedException e) { }
System.out.println("SocketCloser .. closing");
try { acceptor.close(); } catch(IOException e) { e.printStackTrace(); }
}
}
}
Andy Bennett
Valued Contributor

Re: Java 2 HP-UX java.net.PlainSocketImpl.socketClose() hang

A problem fitting the description was logged as a defect on Feb 21st: JAGad51176. It is a duplicate of Javasoft bug 4096914.
David Grigglestone
Occasional Contributor

Re: Java 2 HP-UX java.net.PlainSocketImpl.socketClose() hang

According to Javasoft that was fixed in 1.2 FCS .. seems not in HP-UX 1.3. I did find the HP-UX JVM switch -XdoCloseWithReadPending which seems to workaround the problem, however this should be the default behavior - I shouldn't need a special switch.