Is this a good way to receive a message from a server?
One thing I do with reading from sockets is separate receiving of the data from what the data contains.

Meaning, you may get your information in progressive chunks.....  so receive a chunk of data, then see if you have a complete "Message".  If not, wait for the next chunk of data.  When you have your full "Message"  then you can pass that on to whatever wants it.

In fact what I have done is abstract the idea of a streaming connection so I can interchange serial ports / tcp sockets / and any other streaming type connection.  Have something that receives from a connection, and then do interpreting.