How do I check that the message from recvfrom() is the correct size in C or C++ on windows?
Thank you.
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.
recvfromreturns the number of bytes in the datagram actually received.All you need is
Old answer, off topic
You should declare a variable to hold the size, and pass its address as the
fromlenparameter.recvfromwill fill in the actual size of thedatagramsender’s address (IP and port, so you can send a reply if you want).Then you can test the actual size against what you expected.