http://www.perlmonks.org?node_id=11116745


in reply to Re: udp broadcast
in thread udp broadcast

great! thanks!

I'm still confused why this work this way, since 4210 is not the local port, but the broadcast port. nevertheless it works and i'm happy :)

Replies are listed 'Best First'.
Re^3: udp broadcast
by haukex (Bishop) on May 13, 2020 at 09:35 UTC

    Glad to help!

    I'm still confused why this work this way, since 4210 is not the local port, but the broadcast port.

    It's the port you're listening on, on the local machine. (The sender is not necessarily sending from their port 4210, they may be sending from a random port, but their packets are addressed to port 4210 on the receiving side. Update: You can see this in the tcpdump output you showed: "192.168.0.50.49153 > 192.168.0.255.4210")

    BTW, if you want to get the address from which the packet was sent, you can call $sock->peerhost immediately after the recv.