What will happen if I use recv(sockfd, buffer, len, 0); on a non-blocking socket?
If the socket sockfd is closed or nothing to be read, does the recv() block? (note: the flag in recv () is 0).
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If the socket is marked non blocking, recv will never block. period.
If the socket is fine but there is no data to be read you will get -1 as return value and errno will be set to EAGAIN.
If there is an error (closed socket etc.), you still get a -1 return value but errno will be set to the appropriate value.