最近一直在学习boost asio,尤其是UDP。我熟悉基础知识,但对 UDP 如何处理传入消息有疑问。在本教程中(请参阅此处的源代码:http: //www.boost.org/doc/libs/1_54_0/doc/html/boost_asio/tutorial/tutdaytime6/src.html),UDP 服务器的操作类似于(非常伪代码):
startReceive(){
async_receive(boost::bind(handler),...other params);
}
handler(){
doStuffToDataReceived();
startReceive(); //start the receiving process over again to allow it to receive more data
}
我的问题是,如果数据在它处于“doStuffToDataReceived()”的时间内到达服务器,在它再次开始接收之前,该数据是否会丢失,或者它是否坐在那里等待 startReceive 再次发生然后是立即找回?
谢谢!