On your server side class when the clients socket is created/connected you can call setSOTimeout(timeout in milliseconds) on the clients socket.
When you call the read method on that socket's...