Fix bug with client connect function not clearing previous closed socket state.