You are not logged in.
Pages: 1
Getting IP header from UDP recvfrom call
Is there any way to get the IP and UDP header when calling recvfrom with a UDP socket, or do I have to receive the UDP packet using raw sockets to get these details (like a sniffer)?
I'm kinda wondering if there is some socket option I can set in such a way that I could read this information out of the "buf" parameter in recvfrom (such that in a IPv4 standard header the first byte would be 0x45, etc). Preferably I'm looking to do this on BSD and Linux.
Thanks in advance.
Offline
If you really need the full headers, then I think the only choice is to use a raw or packet socket... If you're only doing this to get at the destination IP from the header, then you may be able to use something like IP_PKTINFO or IP_RECVORIGDSTADDR instead...
Offline
Pages: 1