Fixing creation request to close the socket and the server to correctly wait for socket connections