I have a problem where I have used setSoTimeout(500) to set a timeout of 0.5 second on the connection and read time delays, but it is not actually working and instead timeouts after about 10 seconds like it usually does with this kind of exception. And yes, the IP is valid in this situation.
java.net.ConnectException: Connection timed out: connect
Here is the code :
try {
Socket sock = new Socket(ip, 42042);
sock.setSoTimeout(500);
BufferedInputStream is = new BufferedInputStream(sock.getInputStream());
theNames = theNames + is.read() + ";";
PrintWriter os = new PrintWriter(sock.getOutputStream());
} catch (IOException e) {
System.out.println(e + " | Le serveur a " + ip + " ne reponds pas.");
}
is.read()is an input read if I remember correctly.