InputStream Non Blocking read operation
<p>I have the scenario where i need to confirm that either the server side socket closed the connection or not.So for this i am checking if(in.read() ==-1) if true ,it means that server side closed the connection.
But problem is that if it does not it blocks here as it is blocking call.i need such a solution where i can read non blocking in perticular time or cancel the reading if server end closed the connection.
i am creating like </p>

<pre><code>socket = new Socket();
                 // if server is not available 3 seconds blocking call other wise Exception
                 socket.connect(new InetSocketAddress(serverAddress , serverPort),3000);
</code></pre>

<p>Any help would be appreciated.</p>

<p>Regards,
Aamir</p>
