Hello,
When using boos asio async receiving, my received callback usually looks like this:
void ReceiveCB(const boost::system::error_code& error, std::size_t bytes_transferred)
{
If (error) {
fprintf(stderr, “recv() failes: %s\n”, error.message().c_str());
return;
}
/* process data received */
s.async_receive( boost::asio::buffer(…), & ReceiveCB);
}
I stop calling async_receive() as soon as I get an error. This works good for TCP sockets.
But with UDP sockets, recvfrom() can return e.g. the error ‘connection refused’ after I called sendto() to a peer machine, where no socket is (yet) bound to the destination port number. So, at least after the error ‘connection
refuxed’, I’d better continue calling async_receive_from().
Are there any recommendations on how to decide, whether the receive callback function should re-initiate a receive operation after a receive error or not?
Mario Klebsch
--
Mario Klebsch Actia I+ME GmbH
Mario.klebsch@ime-actia.de
Dresdenstrasse 17/18
Fon: +49 531 38 701 716 38124 Braunschweig
Fax: +49 531 38 701 88 Germany