I have a Java socket connection established with a server A. Server A randomly restarts during the day and my Java socket connection infinitely waits because it thinks that is receiving data. I have set the soTimeout but it is only kicking in while read is still going on. How do I set force a timeout on the socket connection? I want to break the socket connection after a set period of time.
Socket mySocket = new Socket(host, port) ;
mySocket.setKeepAlive(true);
mySocket.setSoTimeout(timeout);