I have an Application (written in C/C++) thats communicating over UDP between many Windows and Linux Hosts inside the local Network (via winsock / Linux-Sockets). I only use one Port and so only one Socket on each host. Some messages are Broadcastet, replies are often Unicast but some are Broadcasts too. Everthing is working so far but:
How can i find out whether a Paket i received (via recvfrom) was a Broadcast or Unicast?
The only solution i found was to send this info inside the Payload or to use different ports. Both are not very nice…
On Linux side you can set
PKT_INFOip(7)socket option withsetsockopt(2), and then userecvmsg(2)to get the destination address of the UDP packet.