title: How to set timeout on client socket connection?
body: <p>I am trying to set the timeout of a connection on the client socket in Java. I have set the <em>connection timeout</em> to 2000 milliseconds, i.e:</p>
  <pre><code>this.socket.connect(this.socketAdd, timeOut);
  </code></pre>
  <p>This I am trying on a web application. When a user makes a request, I am passing values to socket server, but if I don't receive any response in 5 secs the socket should disconnect.</p>
  <p>But in my case the whole request is getting submitted once again. Can any one please tell me where am I going wrong?</p>
  <p>I want to cut the socket connection, if I don't get any response in 5 secs. How can I set it? Any sample code would help.</p>