Added a missing close() function after a unsuccessful connect() call, and removed WSACleanup() when WSAStartup failed.