Jump to content
  • Advertisement
Sign in to follow this  
Jethro_T

Boost ASIO Receive Handler

This topic is 2811 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm using boost::asio::ip::udp::socket::async_receive_from(). Does anyone know if this function guarantees that it's handler function will be called in this order? My code is single threaded so only 1 handler executes at once.

Data written to receiving buffer
Handler executed
Data written to receiving buffer
Handler executed
Data written to receiving buffer
Handler executed
...

I checked the documentation and it doesn't seem to say. Hopefully someone knows, I'm having a very strange issue with my Server's receiving functionality and I'm thinking it might be because I'm expecting things to behave like above.

Share this post


Link to post
Share on other sites
Advertisement
A UDP socket handler will be called exactly once per incoming datagram.

If you use a single thread, I don't believe that the callbacks will be re-ordered compared to the order they arrive on the socket -- but that doesn't really matter, because the UDP datagrams may be re-ordered externally by the network.

If you queue more than one async receive operation, though, they each need to use a different area of buffer data -- you can't re-use the same buffer area for two, simultaneously outstanding, async requests.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!