New JDK 1.4 socket timeout control
Core Java Technologies Technical Tips
int timeout = 500; // half a second
SocketAddress socketAddress =
new InetSocketAddress(host, port);
Socket socket = new Socket();
socket.connect(socketAddress, timeout);