This question has been asked before, yet I just can\'t seem to come to grips with it as small details of all the questions ive ever seen throw me off...
Yes, the relevant socket option is called SO_REUSEADDR. You use setsockopt() to set socket options.
You should normally not close the server's main socket though, instead you should use accept() to create per-client sockets, which can be closed when the client disconnects.