Opened 6 years ago

Last modified 6 years ago

#12151 new Bugs

Example UDP async server stops on error...

Reported by: Micah Quinn <micah.quinn@…> Owned by: chris_kohlhoff
Milestone: To Be Determined Component: asio
Version: Boost 1.61.0 Severity: Problem
Keywords: Cc:

Description

In the boost::asio UDP async server example, if a recv_from error occurs, the server stops receiving completely. The code in question is in the "start_receive()" function:

void handle_receive(const boost::system::error_code& error,
      std::size_t /*bytes_transferred*/)
  {
    if (!error || error == boost::asio::error::message_size)
    {
....
      start_receive();
    }
  }

Should instead be (with start_receive() moved outside the error check):

void handle_receive(const boost::system::error_code& error,
      std::size_t /*bytes_transferred*/)
  {
    if (!error || error == boost::asio::error::message_size)
    {
....
    }
    start_receive();
  }

http://www.boost.org/doc/libs/1_60_0/doc/html/boost_asio/tutorial/tutdaytime6/src.html

Change History (1)

comment:1 by anonymous, 6 years ago

Component: Documentationasio
Owner: changed from Matias Capeletto to chris_kohlhoff
Note: See TracTickets for help on using tickets.