Description
I would like to suggest an added method
IPAddress WiFiUDP::ipDst() to get the destination ip address of a received packet
similar to the existing
IPAddress WiFiUDP::remoteIP()
in the WiFiUDP class.
The use case is the simultaneous use of the same port number for unicast and multicast packet receipt, where one might have a need to treat these packet receipt channels differently.
If I - for a server - register a multicast address for port N and at the same time register a server socket for the same port N, I currently see no way to differentiate whether a packet did arrive because of a client unicast call of because of a client multicast call.
I can make a call to WiFiUDP::remoteIP() to find the address of the packet sender, but there is no way AFAIK to find the destination address of the packet, which I would need in order to resolve unicast from multicast.
The WiFiUDP::read() call will only return data above the UDP layer, so there is no way to look at the relevant packet data directly.
A real case is for the application protocol COAP where port 5683 is used in both cases.
If I should have overlooked another way of achieving this, please feel free to inform me.