开发者

Finding the destination IP address of the received UDP message in boost library

开发者 https://www.devze.com 2023-04-01 21:37 出处:网络
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

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: Get destination address of a received UDP packet .

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 开发者_C百科received packet in the boost library??


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号