It's a socket thing, you'll have to tell the OS that the socket may be used more than once. A nice explanation of socket programming and the associated options can be found
here (
Main page)
Also, it might be a good idea to set up a signal handler for SIGINT, SIGTERM, ..., which cleans up the workspace (close sockets, free() memory, ...) if your program dies.