I tried you code, both client and server..... I had to change one function (I didn't appear to have inet_pton(), so I used inet_aton() instead). And it all worked OK.

I noticed that in your client you do all the correct error checking, but you don't do any in your server. Maybe doing so might help you find the problem.

When you run your server, can you see it listening? (via netstat -an), can you telnet to it?