fixing socket.connect not returning on failure