The for loop method would have worked. The problem with it was that you were waiting for there to be three or more bytes, then reading 4 of them.
If you are going to read 4 bytes, you must wait until there are 4 or more ready to read.
The for loop method would have worked. The problem with it was that you were waiting for there to be three or more bytes, then reading 4 of them.
If you are going to read 4 bytes, you must wait until there are 4 or more ready to read.