avoid endless loop when socket read returns empty string but not EOF