While working on my IRC bot today (joins a channel and responds to things people say to it), I'd find that it's simply not enough to execute a recv() loop to get all the data. I'd also have to actually scan for a "PING" string upon completion of the recv() loop and if not found, repeat the loop again.
another tip you could use is, select(). this allows you to check if theres data wating for you or not. if there isnt you can do other things insted of blocking with a recv().
best to use non-blocking sockets, and event/message notification instead of select