D
Dan McLeran
I'm having alot of trouble getting a Java app on a WindowsXP box to
talk to a Java app on a RedHat Linux 9.0 box. It seems like it should
be trivial but it's not working. My RedHat Linux box has 3 NIC cards in
it, as does my WinXP box. I am attempting to hook 2 of the NIC cards
together with a cross-over ethernet cable and open up a Socket between
them. WinXP see the NIC card as being connected, but I cannot get the
Linux box to establish a Socket with the server. I've put a couple of
code snippets below just in case anyone sees anything obvious.
I have the server running on WinXP:
try {
ServerSocket serverSocket = new ServerSocket(6969, 0,
InetAddress.getByName("192.168.69.1"));
System.out.println("listening on ip address " +
serverSocket.getLocalSocketAddress().toString() + " port " +
serverSocket.getLocalPort());
Socket client = serverSocket.accept();
System.out.println("Connected: " +
client.getInetAddress().toString());
}
catch(final SocketException e) {
e.printStackTrace();
}
catch(final IOException e) {
e.printStackTrace();
}
And the client running on Linux under X windows:
try {
Socket socket = new Socket();
socket.bind(new
InetSocketAddress(InetAddress.getByName("192.168.101.1"), 6969));
System.out.println("bound to " + socket.getLocalSocketAddress());
System.out.println("bound = " + socket.isBound());
socket.connect(new
InetSocketAddress(InetAddress.getByName("192.168.69.1"), 6969), 1000);
System.out.println("Connected: " + socket.isConnected());
}
catch(final SocketException e) {
e.printStackTrace();
}
catch(final UnknownHostException e) {
e.printStackTrace();
}
catch(final IOException e) {
e.printStackTrace();
}
talk to a Java app on a RedHat Linux 9.0 box. It seems like it should
be trivial but it's not working. My RedHat Linux box has 3 NIC cards in
it, as does my WinXP box. I am attempting to hook 2 of the NIC cards
together with a cross-over ethernet cable and open up a Socket between
them. WinXP see the NIC card as being connected, but I cannot get the
Linux box to establish a Socket with the server. I've put a couple of
code snippets below just in case anyone sees anything obvious.
I have the server running on WinXP:
try {
ServerSocket serverSocket = new ServerSocket(6969, 0,
InetAddress.getByName("192.168.69.1"));
System.out.println("listening on ip address " +
serverSocket.getLocalSocketAddress().toString() + " port " +
serverSocket.getLocalPort());
Socket client = serverSocket.accept();
System.out.println("Connected: " +
client.getInetAddress().toString());
}
catch(final SocketException e) {
e.printStackTrace();
}
catch(final IOException e) {
e.printStackTrace();
}
And the client running on Linux under X windows:
try {
Socket socket = new Socket();
socket.bind(new
InetSocketAddress(InetAddress.getByName("192.168.101.1"), 6969));
System.out.println("bound to " + socket.getLocalSocketAddress());
System.out.println("bound = " + socket.isBound());
socket.connect(new
InetSocketAddress(InetAddress.getByName("192.168.69.1"), 6969), 1000);
System.out.println("Connected: " + socket.isConnected());
}
catch(final SocketException e) {
e.printStackTrace();
}
catch(final UnknownHostException e) {
e.printStackTrace();
}
catch(final IOException e) {
e.printStackTrace();
}