server: Use setsockopt and set the socket to reuse addr

This avoids the problem about "Address açlready in use" of the bind function. Also, add an sig handler to
close the socket in the case of SIGINT, and show messages about each syscall that fails.