You should probably collect the value of errno into a local variable at this point.  Otherwise, your final call to recv() in the loop below is apt to set errno, so that your tests of errno after that aren't seeing the errno actually left over by poll() !