c++ - How to find the destination address of a UDP packet using boost::asio? -
i'm developing peer-to-peer communications network utilize on lan in industrial environment. messages are asynchronous, , don't require response. others request-response. request messages (and async messages) sent multicast group, , replies requests sent unicast. each endpoint, therefore, receives udp packets sent multicast group, , receives messages sent using plain unicast.
so far it's working fine, there doesn't seem way in boost::asio find out destination address of received udp packet (using socket.async_receive_from) - whether sent multicast grouping or actual interface. can utilize contents of message infer whether sent multicast or unicast, nice able check destination address.
we using windows 7, transitioning linux in future.
is there way find destination address of udp packet received using boost::asio?
unfortunately not possible boost::asio, , not "the way do" it, seek access transport layer info @ application layer.
so have 2 options:
a) write non-portable scheme code illustration ip_pktinfo or so_bindtodevice on linux. illustration code can found on boost asio mailing list here
b) utilize 2 distinct sockets, 1 multicast , 1 unicast. hence need specify listen_address other "0.0.0.0" on each socket.
udp::endpoint(address_v4::from_string("239.192.152.143"), 6771)
this question on might helpful: using specific network interface socket in windows
c++ networking boost udp boost-asio
No comments:
Post a Comment