Reputation: 4223
If I have a connected socket and and it is waiting(blocking) to receive some data from the remote machine but somehow or other, the remote machine loses its connection, how can I make it such that it stops blocking but times out after a certain period of time without receiving any data? I'm using a Scanner object to read data from the socket and a PrintWriter object to write,
// Get InputStream
scanner = new Scanner( clientSocket.getInputStream() );
// Get OutputStream
printWriter = new PrintWriter( clientSocket.getOutputStream(), true );
Upvotes: 5
Views: 6405