Apologies if this is a newbie question. I've had very little call for Streams so far in my coding life. I've inherited some code that I'm trying to make some sense of.
Imagine two instances of an object. They are communicating over ethernet ports. Each object has an
Object RXTransmission(InputStream is, OutputStream os)
and
boolean TXTransmission(InputStream is, OutputStream os, Object o)
The point is to transmit the 'o' object from one place to the other.
The code uses CRC32 checking to determine if the object was successfully sent. And it appears that they do so in a hand-shaking manner.
"
TX:Here's the object.
RX: I have that object, I've calculated the checksum, I'm sending you the checksum.
TX:I have the checksum, and it matches the one I made before sending. I'm sending you a Boolean 'true'.
RX:I see that 'true' and so I'm convinced the object was received successfully.
"
Here's the real question.
Will calls to readObject() (on ObjectInputStream) block until there is an object to read on that stream? Or will they return immediately with 'null' ? I've read somewhere that stream in
java are "blocking". Is this what is meant (and what NIO is supposed to 'fix')?
The answer to the first question must be yes, or else I'll have to scratch my head a bit more.