I am working with multicast UDP messages. I need to compare the destination IP address of the received packet with the multicast address of the channel, the receiver is supposed to be listening on to make sure that it is not receiving messages multicasted over a different multicast channel.
I know that I can find out the destination IP address by using UNIX sockets using recvmsg() and then doing all the stuff mentioned here: Obtener la dirección de destino de un paquete UDP recibido .
But I have been using boost library ASIO sockets and although there is receive_from() corresponding to recvfrom() funcn but I can't find any func with a similar functionality as recvmsg(). Can anybody help me out here.. Is there a way to find out the destination IP address of the received packet in the boost library??
preguntado el 30 de agosto de 11 a las 22:08
Let's take a step back. Why do you think you need to be looking at the destination address and filtering it in userspace? Shouldn't the operating system be doing that for you? Probably it should!
Are you actually receiving datagrams that you don't want? If so, it's likely because you haven't done sufficiently strict setup of the listener. For example, you should be binding and listening only to a specific multicast group (address), port, and interface. Perhaps you're neglecting to specify some part of that? If that's not it, perhaps you'll explain what's going on that makes you ask this question.
The typical workaround for not having access to destination address is to open one socket per multicast group and match the socket to the address within your application.