The hardest part about sockets is knowing when to stop reading. You can invent a line-oriented protocol, or use some other indication (like a byte count followed by that many bytes).
Knowing what to use is an art call, decided by experience and study of the prior art. Good luck in your quest!
Comment on Re: Can I read a line from a socket without the socket sending \n?