Marco Spinetti wrote:
but I can't understand how it is useful.
One reason the API is designed that way is because in many cases where network apps read from a peer, there is no set number of bytes to expect to read; the app simply decides the maximum amount it can handle at a time and passes a buffer of that size to the i/o layer.
Also of benefit, even when the app knows it must read a certain number of bytes, is the ability to know the progress of the data transfer, which returning partial bytes allows.
