fixing up crash when using closed socket