re-work logic around socket error/close