Sometimes I seem to get 0, which means that all I got was a header, does that mean I should assume that I received a FIN and close that socket?
Thanks in advance!
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.
Yes. Zero means, generically, end-of-file. What “end of file” means depends on what kind of file descriptor you are using.
In the context of a TCP socket, the only way that I know of that you can read zero is if a FIN is received. By contrast, if a RST is received
read()would return-1witherrno == ECONNRESET.