Can anybody explain me this statement!
pin.sin_addr.s_addr = ((struct in_addr *)(hp->h_addr))->s_addr;
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.
Takes
hp->h_addr, and casts it tostruct in_addr*. The cast may have different reasons. Perhapshp->h_addrisvoid*and the cast is needed to tell the compiler what type it should use for findings_addr. It may also be another struct that has anin_addras its first memberThen, casting
socket*toin_addr*would be valid because on its address there is ain_addrat the beginning. After the cast, the members_addris accessed. These types are common in network programming under POSIX, and don’t look like in my above example, but the above could have been the situation at hand.