Reputation: 121
Currently I come across a situation that I would like to read the inputstream to a byte array which only contains a single byte. I repeat to do this for a certain number of times to make sure I get the corresponding length of bytes. For example,read 40 times for 40 bytes. But in the other side of this socket, it writes 512 bytes in each write method.(Actually in the most cases the read buffer is 512 bytes,just in a certain condition I read one byte a time). I am wondering in this case if the sending socket still writes 512 bytes over the network each time and the receiving socket receives all of them and stores them in a local byte array and the read method reads a single byte each time from the local array or the sending socket writes only 1 byte each time as well? This question may sound kind of confused,Hopefully I made it clear.Any help is much appreciated!
Upvotes: 0
Views: 274
Reputation: 310860
It blocks until some data is available in the kernel's socket receive buffer, and then transfers as many bytes as are available.
Upvotes: 3