<p>在socket I/O中,我可以知道<code>objectinputstream</code><code>readObject</code>如何知道要读取多少字节?内容长度是封装在字节本身内,还是只是读取缓冲区中所有可用的字节?在</p>
<p>我问这个是因为我指的是Python套接字how-to,它说</p>
<blockquote>
<p>Now if you think about that a bit, you’ll come to realize a
fundamental truth of sockets: messages must either be fixed length
(yuck), or be delimited (shrug), or indicate how long they are (much
better), or end by shutting down the connection. The choice is
entirely yours, (but some ways are righter than others).</p>
</blockquote>
<p>然而在另一篇文章中,@DavidCrawshaw提到</p>
<blockquote>
<p>So readObject() does not know how much data it will read, so it does
not know how many objects are available.</p>
</blockquote>
<p>我很想知道它是怎么工作的。。。在</p>