Hello everyone, it became necessary to accept packets from 4 devices using the UDP protocol. I use for this boost :: asio. The problem is this: when broadcasting, broadcast is used, when connecting to devices and receiving, I get the same (!) Data packets from everyone, although through wireshark it can be seen that different ones are sent. Here is an example of how I try to accept data:
io_service service; ip::udp::socket sock_mu(service); ip::udp::socket sock_s1(service); ip::udp::endpoint ep_m(ip::address::from_string("0.0.0.0"), port); ip::udp::endpoint ep_s1(ip::address::from_string("0.0.0.0"), port); sock_mu.open(boost::asio::ip::udp::v4()); sock_s1.open(boost::asio::ip::udp::v4()); sock_mu.set_option(boost::asio::socket_base::broadcast(true)); sock_s1.set_option(boost::asio::socket_base::broadcast(true)); sock_mu.set_option(boost::asio::ip::udp::socket::reuse_address(true)); sock_s1.set_option(boost::asio::ip::udp::socket::reuse_address(true)); sock_mu.bind(ep_m); sock_mu.bind(ep_s1); ip::udp::endpoint ep1(ip::address::from_string("192.162.2.101"), port); ip::udp::endpoint ep2(ip::address::from_string("192.168.2.102"), port); sock_mu.receive_from(boost::asio::buffer(buf_m2, 16384), ep1); sock_s1.receive_from(boost::asio::buffer(buf_m2, 16384), ep2);
The port and IP addresses of the devices are correct. When I try to connect to the correct IP address of the device, I don’t receive any packets at all. Those. bind to any (0.0.0.0) address works, but I get the same packages. And connect (192.168.2.101) for example - no. I hope explained clearly) What am I doing wrong?