Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Socket() returning false positive

843790Apr 7 2009 — edited May 27 2009
I ran into this problem on Vista again I thought I solved it in previous thread [Thread 5369193|http://forums.sun.com/thread.jspa?forumID=536&threadID=5369193] but now when I use this test the Socket connection does not throw an exception for an IP address that does not exist it returns true for isConnected().
Socket testConnect;
connected = false;
try {
testConnect = new Socket();
SocketAddress addr = new InetSocketAddress(mjpgIPAddress, 80);
testConnect.connect(addr, 300);
Thread.sleep(300);

if (testConnect.isConnected()){ .......

Say I am trying to test the socket connection for an IP that doesn't exist the connection check returns true. It does this on my Vista x64 machine but not on my XP machine. Can anyone help cause it is really annoying?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 24 2009
Added on Apr 7 2009
21 comments
498 views