EDIT: Removed code/explanation because this project has been given again and students can easily find the solution via this post.
To clarify what happened, I simply passed the wrong length/size in my recvfrom() call.
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.
In this line:
You pass
BUFFER_LENas the length (256), butsendHostIPis only of lengthMAXHOSTNAMELEN(64).This causes
recvfrom()to overflow that buffer. The same problem occurs when you read in tolocalHostIP.