Boost C++ Libraries: Ticket #13193: multiple sockets (reuse_address) + multiple io_service = packages never received https://svn.boost.org/trac10/ticket/13193 <p> In example program, we open several UDP sockets (each on same address/port - with reuse_address), and they use several io_service. </p> <p> The result is that async_receive_from never reads any data. </p> <p> 1) N sockets (same addr/port), using N various io_service - doe not work 2) N sockets (each own port), using N various io_service - works 3) N sockets (same addr/port), but using same 1 io_service - works 4) 1 socket - works </p> <p> The full test case is in github: </p> <p> <a class="ext-link" href="https://github.com/rfree-d/cppfuns/tree/79093a5458867ddbf0d36f0170a78465194370a4/asio_udp_srv"><span class="icon">​</span>https://github.com/rfree-d/cppfuns/tree/79093a5458867ddbf0d36f0170a78465194370a4/asio_udp_srv</a> </p> <p> if you run "make run" then program starts using "mport" option - each socket gets own port (so no need for the reuse flag) - and program works fine. </p> <p> if you run "make run_bug" then it is started without the "mport" and all sockets listen on port 9000 - and then the program does not work </p> <p> if you run the binary with no options then it shows usage (or grep sources for 'options'). </p> <p> You can test program by sending data to UDP 9000 localhost, or just build test program in other directory up: </p> <p> <a class="ext-link" href="https://github.com/rfree-d/cppfuns/tree/79093a5458867ddbf0d36f0170a78465194370a4/asio_udp_cli"><span class="icon">​</span>https://github.com/rfree-d/cppfuns/tree/79093a5458867ddbf0d36f0170a78465194370a4/asio_udp_cli</a> </p> <p> there "make", and run it with options like "127.0.0.1 9000" it is interactive, to send many data use: </p> <p> aaa 1000 100000 </p> <p> for big packet sent once use </p> <p> aaa 1000 1 </p> <p> to send one packet with string "exit" use </p> <p> exit 1 1 </p> <p> Tested on Linux Debian 8 and 9. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13193 Trac 1.4.3 anonymous Tue, 05 Sep 2017 14:36:31 GMT <link>https://svn.boost.org/trac10/ticket/13193#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13193#comment:1</guid> <description> <p> Formatting fix: </p> <p> 1) N sockets (same addr/port), using N various io_service - does not work </p> <p> 2) N sockets (each own port), using N various io_service - works </p> <p> 3) N sockets (same addr/port), but using same 1 io_service - works </p> <p> 4) 1 socket - works </p> <p> For clarity: </p> <p> this program is supposed to receive UDP data (and throw it away, performance test) using multiple threads/buffers, and optionally multiple sockets and/or io_service. </p> <p> When we turn all of this on, many sockets and threads and io_services, if they use same addres+port (via reuse addr) then program shows receive speed 0 and count 0. (except for spurious receiving 1 packet from time to time, not sure what this possible bug is about). </p> <p> If we either use different ports so the reuse-port is not needed (by adding command line option "mport" at end as in Makefile make run), or if we use just 1 io_service, then when we send the data (e.g. from the sibling test program linked above) then all works (e.g. 100 MB/sec and more). </p> <p> p.s. you can enable/disable some debug by toggling the "#if 0" at very top of program. </p> </description> <category>Ticket</category> </item> </channel> </rss>