I have this socket implementation in java which uses timeout:
try {
socket = new Socket();
socket.connect(new InetSocketAddress(ip, port), 5000);
} catch (SocketException e2) {
System.out.println("Something wrong with the socket: " + e2);
}
The ip and port is closed, so connection cannot be made. But the timeout here does not work. It does not wait for 5 seconds and then return an error.
This code is located in constructor and calls from runnable class. May this be the reason?