Re: Possible XP Socket Bug?
Knute Johnson wrote:
John B. Matthews wrote:
In article <49c27e77$0$25089$b9f67a60@news.newsdemon.com>,
Knute Johnson <nospam@rabbitbrush.frazmtn.com> wrote:
[...]
Thanks very much for trying it. For some reason, I'm still not
getting the exception with this test program although it works in
other programs. It's very strange.
FWIW, I tried it on Mac OS X 10.5.6, Java 1.5.0_16. Inside the LAN, I
saw "Connection refused" for ports without a listener; I saw "true"
for ports with a listener. I used netstat to see the results. I also
got warnings about unauthorized connections from the application
firewall.
You might use netstat to see the internal state of whatever port is
giving anomalous results.
<code>
import java.io.*;
import java.net.*;
public class KJTest {
public static void main(String[] args) throws Exception {
int port = args.length > 0 ? Integer.valueOf(args[0]) : 8080;
Socket s = new Socket("localhost", port);
System.out.println(s);
System.out.println("connected to: " +
s.getInetAddress().getHostName());
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(
s.getOutputStream()));
bw.write("hello world\n");
System.out.println("data written");
bw.close();
System.out.println(s.isClosed());
}
}
</code>
There is something really strange going on. I'm sure this is the same
problem that other fellow was having a few weeks back and I for one
thought he must have something hosed. But now I think their is some
sort of bug somewhere that is causing this.
C:\Documents and Settings\Knute Johnson>java KJTest 10101
Socket[addr=localhost/127.0.0.1,port=10101,localport=2913]
connected to: localhost
data written
true
C:\Documents and Settings\Knute Johnson>netstat -a | grep 10101
C:\Documents and Settings\Knute Johnson>
Here are two tests that I captured with Wireshark. The first is using
the code above to connect to my server computer that has all ports set
to DROP. The address is 216.240.58.140 so you can tell which is which.
You will notice that no ACK or RST packets were returned as expected
with the firewall set to DROP. The next set of packets, to
204.212.38.2, have the RST return packets telling the client that the
connection is rejected. It tries three times and gets the same answer
all three times.
In both cases the test program does NOT throw an exception and shows
that it is connected. But as you can see from the Wireshark trace, it
can't be.
No. Time Source Destination Protocol
Info
22 17.308476 192.168.3.5 216.240.58.140 TCP
responsenet > 33333 [SYN] Seq=0 Win=65535 Len=0 MSS=1460 WS=4
25 20.237612 192.168.3.5 216.240.58.140 TCP
responsenet > 33333 [SYN] Seq=0 Win=65535 Len=0 MSS=1460 WS=4
33 26.253169 192.168.3.5 216.240.58.140 TCP
responsenet > 33333 [SYN] Seq=0 Win=65535 Len=0 MSS=1460 WS=4
137 61.354315 192.168.3.5 204.212.38.2 TCP
nsws > 33333 [SYN] Seq=0 Win=65535 Len=0 MSS=1460 WS=4
138 61.377004 204.212.38.2 192.168.3.5 TCP
33333 > nsws [RST, ACK] Seq=1 Ack=1 Win=0 Len=0
139 61.908965 192.168.3.5 204.212.38.2 TCP
nsws > 33333 [SYN] Seq=0 Win=65535 Len=0 MSS=1460 WS=4
140 61.925229 204.212.38.2 192.168.3.5 TCP
33333 > nsws [RST, ACK] Seq=1 Ack=1 Win=0 Len=0
142 62.455833 192.168.3.5 204.212.38.2 TCP
nsws > 33333 [SYN] Seq=0 Win=65535 Len=0 MSS=1460 WS=4
143 62.478696 204.212.38.2 192.168.3.5 TCP
33333 > nsws [RST, ACK] Seq=1 Ack=1 Win=0 Len=0
--
Knute Johnson
email s/nospam/knute2009/
--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access