I'm programming an embedded Linux device to send a reply to an incoming
UDP broadcast packet. I spent a few hours today trying to figure this
out, and it looks like I might be resorting to raw sockets with custom headers that I've written by myself byte by byte.
Let's say the incoming UDP broadcast datagram has source port 5432, and destination port 1011.
I want the reply packet I send to have source port 1011 and destination
port 5432. I thought this would be possible by simply taking the address structure from the 'recvfrom' function and passing it verbatim to the 'sendto' function, however this doesn't work (it doesn't send the packet out).
It seems as though I would have to create a new UDP socket and then send
the reply packet on that new socket, however the problem here is that
the source port will be an ephemeral port (e.g. 17654 instead of 1011).
I played with all the settings like SO_BROADCAST but no joy.
|Location:||Huddersfield, West Yorkshire, UK|
|Nodes:||8 (1 / 7)|