Fixed minor bug when socket isn't in correct state