Fixed bug in socket wait routine which could cause erroneous retries on fatal errors