Think about Loose Coupling | |
PerlMonks |
Re: (OT) Getting the source hardware address of received UDP packets?by ikegami (Patriarch) |
on Jun 01, 2006 at 07:59 UTC ( [id://552993]=note: print w/replies, xml ) | Need Help?? |
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 Section
Seekers of Perl Wisdom
|
|