This is necessary when using ObjectInputStream and ObjectOutputStream , since they send a header over the stream before the first record is called. A call to flush() will send this header to the remote side.
According to spec, the header exists from the following contents:
magic version
If the header does not appear at the time of assembling the ObjectInputStream, this call will hang until it receives the bytes of the header.
This means that if the corresponding protocol is written using ObjectStream s, it must be hidden after creating the ObjectOutputStream .
source share