Reading what's available from Socket without blocking
<p>I am working on a server which reads data sent by the Client, but the size is not known neither can I change the client to send the size.</p>

<p>I want to read the data from Client till it blocks and waits for Server's response. I tried using <code>available()</code>, it works sometimes but sometimes it just returns zero even when there's some data in Stream. </p>

<pre><code>while((len = in.available()) != 0)
    in.read(b,0,len);
</code></pre>

<p>Is there any way to do this in JAVA? I'm aware of asynchronous methods, but have never tried that, so if someone can provide a short example.</p>
