So, I’m developing an Android app that communicates with server via a socket. Now, the phone will constantly be getting data from a server. The packets will not all be the same size. The first byte of the packet is the type, and then, if applicable, the next four bytes indicate the size. After that, is that many number as floats (4 bytes).
What’s the best way to read these in? calling readByte(), readFloat(), readFloat(), etc. or use these Datagram things that I stumbled upon? Explain why. If you want more details to make a better suggestion, please ask.
Thanks,
Sounds like you want to DataInputStream and BuferredInputStream your sockets input stream.
You don’t want Datagrams because that is for UDP not sockets.
Then I would use readByte(), optionally readInt() followed by readFloat() etc.