Corrected version : includes a new function to close socket, no longer binds a port to 'client' sockets.