How to distinguish between UDP broadcasts and Unicast?

I have an application (written in C / C ++) that transmits UDP between many Windows and Linux hosts on a local network (via winsock / Linux-Sockets). I use only one port, and only one Socket on each host. Some messages are Broadcastet, responses are often unicast, but some are also broadcast. Everthing still works, but:

How can I find out if I received Paket (via recvfrom) broadcast or unicast?

The only solution I found was to send this information inside the payload or use different ports. Both are not very pleasant ...

+3
source share
1 answer

Linux PKT_INFO ip(7) setsockopt(2), recvmsg(2), UDP-.

+3

All Articles