A strange error with Sockets

P

pieterblomme

Hi,
I was having some problems with sockets, so I did some research to what
could cause the error. I have found what caused it, but I'm affraid I
don't have a single clue of how to solve it.

I created a ServerSocket on the first comp, listening to port 5000. No
problems occurred, the ServerSocket was succesfully created.
Then, I created a Socket on the second comp, who connected to that host
on port 5000.
Several minutes later, the connection timed out without having made a
succesfull connection.
All this was done using native Java.net API code, and since that has
been tested, the error can't have been caused by the code.

What could possibly cause this problem?
I did this test on a local network consisting out of a router, a Gentoo
computer and a Windows laptop.

pieter
 
C

Chris Uppal

pieterblomme said:
I was having some problems with sockets, so I did some research to what
could cause the error. I have found what caused it, but I'm affraid I
don't have a single clue of how to solve it.

Get yourself a copy of Ethereal (free at http://www.ethereal.com/) -- you are
just wasting your own time if you attempt any kind of network trouble-shooting
without it (or an equivalent).

-- chris
 
S

Steve Horsley

Chris said:
Get yourself a copy of Ethereal (free at http://www.ethereal.com/) -- you are
just wasting your own time if you attempt any kind of network trouble-shooting
without it (or an equivalent).

-- chris

Chris is right - Ethereal will tell you exactly what's happening.
But two quick questions:
Can one computer ping the other?
Is either one running a firewall?

Steve
 
G

Gordon Beaton

I created a ServerSocket on the first comp, listening to port 5000.
No problems occurred, the ServerSocket was succesfully created.
Then, I created a Socket on the second comp, who connected to that
host on port 5000. Several minutes later, the connection timed out
without having made a succesfull connection.

All this was done using native Java.net API code, and since that has
been tested, the error can't have been caused by the code.

What could possibly cause this problem? I did this test on a local
network consisting out of a router, a Gentoo computer and a Windows
laptop.

One guess: Your server code did not accept() the connection.

Second guess: the second client has DNS or routing issues. Does the
connection fail when you specify a hostname, or even when you specify
an IP address for the host?

Post your server code. Post your routing tables. Try pinging between
the hosts using hostnames and using IP addresses.

/gordon
 
J

Joseph Dionne

pieterblomme said:
Hi,
I was having some problems with sockets, so I did some research to what
could cause the error. I have found what caused it, but I'm affraid I
don't have a single clue of how to solve it.

I created a ServerSocket on the first comp, listening to port 5000. No
problems occurred, the ServerSocket was succesfully created.
Then, I created a Socket on the second comp, who connected to that host
on port 5000.
Several minutes later, the connection timed out without having made a
succesfull connection.
All this was done using native Java.net API code, and since that has
been tested, the error can't have been caused by the code.

What could possibly cause this problem?
I did this test on a local network consisting out of a router, a Gentoo
computer and a Windows laptop.

pieter

First, rule out a problem with your java code by testing on one system, either
the Gentoo or Windows laptop, i.e. start server in one window and client in
another on the same system.

Second, I'll assume you are using Windows XP, and I have found in you add your
"remote" system in your Windoze hosts file, located on
%SystemRoot%\system32\drivers\etc, will reduce the connect time, but is not
the cause of your connection failure.

If your java code works on both systems locally, i.e. server and client
running in one system, then insure your router is not blocking the port your
are using, and/or your firewall settings on either Windoze or Gentoo allow
access to the port 5000.

Joseph
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top