Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>1 : This might not be a bug !</strong></p> <p>[assuming that there is readable data in the buffer]...</p> <p>You would expect a -1 at the end of the stream... See <a href="http://docs.oracle.com/javase/1.4.2/docs/api/java/nio/channels/SocketChannel.html#read%28java.nio.ByteBuffer%29" rel="nofollow">http://docs.oracle.com/javase/1.4.2/docs/api/java/nio/channels/SocketChannel.html#read%28java.nio.ByteBuffer%29</a> </p> <p>If you are continually recieving a positive value from the read() call, then you will need to determine why data is being read continually. </p> <p>Of course, the mystery herein ultimately lies in the source data (i.e. the SocketChannel which you are read data from).</p> <p><strong>2: Explanation of your possible problems</strong></p> <p>If your socket channel is coming from a REAL file, which is finite then your file is really big, and eventually, the read() operation will return 0... eventually...</p> <p>If, on the other hand, your socket channel is listening to a source of data which you EXPECT to be finite (i.e. a serialized object stream, for example), I would double check the source --- maybe your finite stream is simply producing more and more data... and you are correctly consuming it. </p> <p><strong>3: Finally some advice</strong></p> <p>A trick for debugging this type of error is playing with the ByteBuffer input to your read method : the nice thing about java.nio's ByteBuffers is that, since they are more object oriented then the older byte[] writers, you can get very fine-grained debugging of their operations. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload