Hey zeion.
The suggestion I have is to use data structures for packets where the structure itself has a length parameter within the header (which is sent first).
Then what you do is that as you receive more data, you basically check after you have acknowledged that you have a valid header, that you have the number of bytes that are specified in that header.
If you have the number of bytes specified in the header then you take all this data and store it somewhere as a complete packet to be processed.
What you can do with this model is that you have multiple packet types and each packet can have a call-back routine that handles an event of getting a packet.
You can associate packets with sessions and then when you get the data for a session, the session will update its status.
If you want to wait until you get the full name, you can basically use a mutex associated with the session and when the callback is called for the client name packet for that session, the mutex is changed in state and you can grab the client name from the appropriate data structure.
You can also in the mutex loop, put a timeout value that is checked periodically.
The reason why you would use callbacks for every kind of packet is because you can add as many network protocols as you want, and the mechanism to handle all of these is streamlined which means adding new packet types is really really simple.