I don't see any call to setsockopt(server, SOL_SOCKET, SO_REUSEADDR, ...) which means the server socket may fail to bind to the port if you run the server repeatedly. In that case, the call to bind() may end up returning -1 and any further calls to accept() will return -1 as well.

Check the return value of bind(). If it is -1, print out the last error message with this:

Code:
perror("bind()");
It'll probably tell you something about the address already being in use.