Boost logo

Boost Users :

Subject: Re: [Boost-users] asio UDP message packet loss even on localhost?
From: Ákos Maróy (akos_at_[hidden])
Date: 2010-10-22 09:53:52


Igor,

> I run your code (Win7, MSVC10, boost 1.44), and I can't reproduce the
> issue you describe, the output is always:
> b sent 2000 messages
> a received 2000 messages

I gave it a shot using boost 1.44, freshly downloaded & compiled, but I
get the same results. the pattern is the same: up until a certain number
of packets, everything is received. but there's an obvious breaking
point, after which only a few packets will be received, maybe less than
five.

one way I could make it send / receive all the packets was to add a
millisecond of sleep after each send:

    for (unsigned int i = 0; i < 2000; ++i) {
        std::stringstream sstr;
        sstr << i;
        b.send(endp_a, sstr.str());

        boost::this_thread::yield();
        boost::this_thread::sleep(boost::posix_time::milliseconds(1));
    }

this indicates the problem to be a threading issue. but wouldn't a
yield() be enough?

putting in a 1ms sleep every 100 sends also works most of the time:

    for (unsigned int i = 0; i < 2000; ++i) {
        std::stringstream sstr;
        sstr << i;
        b.send(endp_a, sstr.str());

        if (i % 100 == 0) {
            boost::this_thread::yield();
            boost::this_thread::sleep(boost::posix_time::milliseconds(1));
        }
    }

but putting the 1ms sleep in every 1000 sends will break things again.

the results seem to be the same with boost 1.40 and 1.44.

> Anyway, if I read your code correctly, you assume that all these
> messages should be sent/received within 1 second, don't you? What if
> you increase this value?

giving 1 seconds or 5 seconds gives the same result.

Akos


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net