recv "returns the address of the sender if SOCKET's protocol supports this" (which it does). I don't know if the destination address is available.
Update: Disregard the above. I misread your question. Time for bed.
The source address for UDP is an IP address. Ethernet packets can encapsulate IP packets, but they are completely unrelated. Neither the sender nor the receiver needs to use Ethernet to send or receive UDP packets. Asking for the Ethernet address for an IP address is akin to asking for the street address for an IP address. It may be possible, but it requires an external protocol (like ARP?).
If you do receive your IP packets from an Ethernet, the source address on the packet will be the one of your router and not the one of the computer sending the UDP packet (unless the sender is on your LAN).
By the way, I don't think getpeername works on UDP sockets, since there is no peer associated with a UDP socket. They are "unconnected". That's why the function that returns the sender's address (recv) is associated with a packet, not a socket.
In reply to Re: (OT) Getting the source hardware address of received UDP packets?
by ikegami
in thread (OT) Getting the source hardware address of received UDP packets?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |