Operating System - HP-UX
1833569 Members
4154 Online
110061 Solutions
New Discussion

Re: Java Exception when calling socketAccept()

 
Mike Warne
New Member

Java Exception when calling socketAccept()

Hi,
I am not able to run any Java 1.2 or 1.3 software that accepts a tcp connection from a client machine. eg Tomcat.

Here is the exception that is thrown:
java.net.SocketException: Socket closed
at java.net.PlainSocketImpl.socketAccept(Native Method)
at java.net.PlainSocketImpl.accept(Unknown Source)
at java.net.ServerSocket.implAccept(Unknown Source)
at java.net.ServerSocket.accept(Unknown Source)
at tcpServer1.main(tcpServer1.java:42)

The system is a 2 CPU - L1000 running hpux 11.0
We do not have this problem on another L1000 running 11.0. (Single CPU).

We have verified that all the patches listed for java are applied. http://www.hp.com/products1/unix/java/infolibrary/patches.html

Any ideas, we can't use any Java application servers on this machine!

Here is a simple server that fails. It echos lines of input.

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

public class tcpServer1 {
private static OutputStreamWriter out;

public static void main (String args[]) {
int port;
ServerSocket server_socket;
BufferedReader input;
try {
port = Integer.parseInt(args[0]);
} catch (Exception e) {
port = 9000;
System.out.println("port = " + port + " (default)");
}
try {
server_socket = new ServerSocket(port);
System.out.println("Server waiting for client on port " + server_socket.getLocalPort());
// server infinite loop
while (true) {
Socket socket = server_socket.accept();
System.out.println("New connection accepted " + socket.getInetAddress()
+ ":" + socket.getPort());
input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
// print received data
try {
out = new OutputStreamWriter(socket.getOutputStream());
while (true) {
String message = input.readLine();
if (message == null)
break;
out.write(message + "\r\n");
out.flush();
}
} catch (IOException e) {
System.out.println(e);
}
// connection closed by client
try {
socket.close();
System.out.println("Connection closed by client");
} catch (IOException e) {
System.out.println(e);
}
}
} catch (IOException e) {
System.out.println(e);
e.printStackTrace();
}
}
}


Thanks,
Mike Warne
mike.warne@pihana.com
1 REPLY 1
Ricardo Bassoi
Regular Advisor

Re: Java Exception when calling socketAccept()

Hi Dan,

Try to check:

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x0b1172106351d5118fef0090279cd0f9,00.html

Regards,

Bassoi
If you never try, never will work