> When I create a socket such as Socket sock = new Socket(address, port)
> and I pass some garbage value to address field like (123334) or
[quoted text clipped - 3 lines]
> then java does throw an exception, but if I only have numbers, it does
> not. What is going on?
The binary address 123334 is not garbage. It's perfectly legal to use
the "computed" IP number instead of the byte-separated version people
usually use.
For instance, the IP address called 10.0.0.1 is really
(10 * 1<<24) + (0 * 1<<16) + (0 * 1<<8) + 1 = 167772161
However, IPv4 addresses are only 32 bits (4 * 8) so any value larger
than 4294967295 should give an error.
Java should try and resolve any legal address you pass to the Socket
constructor.
Steve Horsley - 30 Sep 2003 18:21 GMT
>> When I create a socket such as Socket sock = new Socket(address, port)
>> and I pass some garbage value to address field like (123334) or
[quoted text clipped - 17 lines]
> Java should try and resolve any legal address you pass to the Socket
> constructor.
Hmm. I didn't know that. So I guess that the reason it doesn't throw an
exception in unix is that the timeout for a tcp connection attempt is
rather longer than in windows, and you're not waiting long enough (several
minutes).
Steve