Boost logo

Boost Users :

Subject: Re: [Boost-users] "event-driven" async-receive
From: Alexander Carôt (Alexander_Carot_at_[hidden])
Date: 2014-10-25 05:51:02


Hi Andreas and Niall,

thanks a lot for responding to my question !

>I have question regarding the async_receive_from – operation (using UDP):
>
>Right now I have a thread, which triggers the receive call in constant
>intervals. This works allright if the sender sends data in the same
>interval
>or larger intervals.

>Now, why would you do that? It doesn't seem to make any sense to 'poll'
>the socket for data...

Yes, you are right. Obviously I misunderstood the boost async concept and
will now implement it as you stated below. In fact this is equal to the Qt
principle and this is exactly what I need.

In case of further implementation issues I might get back - otherwise all
is good :-)

Thanks,
best

Alex

>
>However, if the send intervals are (much) smaller (or if multiple senders
>exist) the receive-operation is not triggered often enough.
>
>Eventually I’d like the receiving socket to behave in an „event-driven
>“ manner – so, whenever data is there the receive-handler should be
>invoked.

This is exactly how async_receive works, you call async_receive with a
handler callback
which gets called when either an error occurs or data has been received.
In the handler callback, you do whatever you do with the data and then
call async_receive again to wait for the next packet;
I think this is exactly what you want?

Am 24.10.14 01:07 schrieb "Niall Douglas" unter
<s_sourceforge_at_[hidden]>:

>On 23 Oct 2014 at 10:53, Alexander Carôt wrote:
>
>> I have question regarding the async_receive_from - operation (using
>>UDP):
>>
>> Right now I have a thread, which triggers the receive call in constant
>> intervals. This works allright if the sender sends data in the same
>>interval
>> or larger intervals.
>>
>> However, if the send intervals are (much) smaller (or if multiple
>>senders
>> exist) the receive-operation is not triggered often enough.
>>
>> Eventually I´d like the receiving socket to behave in an "event-driven
>> " manner - so, whenever data is there the receive-handler should be
>>invoked.
>>
>> I used to work with Qt, which works this way (via signals/slots) but
>>since I
>> moved to boost I wonder how I can reproduce this behavior.
>>
>> Can anyone tell how to approach this ?
>
>Always keep an async_receive() pending at all times and supply a
>thread pool of executors for asio to issue callbacks onto. You can
>easily peg a 1Gbit ethernet connection with a low CPU usage with that
>alone.
>
>If you need to max out a 10Gbit or 40Gbit ethernet connection, come
>back to us. Those have non-trivial design requirements.
>
>Niall
>
>--
>ned Productions Limited Consulting
>http://www.nedproductions.biz/
>http://ie.linkedin.com/in/nialldouglas/
>
>
>_______________________________________________
>Boost-users mailing list
>Boost-users_at_[hidden]
>http://lists.boost.org/mailman/listinfo.cgi/boost-users


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