add a timeout socket java code example
Example: java socket timeout
Socket socket = new Socket(); // 1000 milliseconds
socket.connect(new InetSocketAddress(ipAddress, port), 1000);
Socket socket = new Socket(); // 1000 milliseconds
socket.connect(new InetSocketAddress(ipAddress, port), 1000);