It'll be a day or two before I have time. I'm waiting for a visitor right now. Nothing except the strerror jumped out at me immediately. And the manner in which you're handling the sending and receiving of messages depends on what you're actually trying to do, which I would need to try to figure out which would take time. But off-hand I'm not seeing how the client's user can quit the program since I don't see any way except a networking error to get out of that loop.