0
即阻塞版本將返回-1錯誤。Boost ASIO如何receive_from返回底層套接字錯誤?
更重要的是,您怎麼知道通話失敗?不
的boost ::支持ASIO ::知識產權:: UDP ::插座:: receive_from()返回-1錯誤
正常BSD套接字API調用receive_from將返回-1錯誤,你可以看看errno的具體錯誤代碼。升壓版本是否也一樣?
好吧,我試圖通過超負荷這樣的:
while(true){
boost::system::error_code ec;
size_t length = socket_.receive_from(
boost::asio::buffer(buffer, buffer_size),
sender_endpoint, ec);
/// ... other code
}
但我得到的編譯此錯誤:
error: no matching function for call to ‘boost::asio::basic_datagram_socket<boost::asio::ipdp, boost::asio::datagram_socket_service<boost::asio::ip::udp> >::receive_from(boost::asio::mutable_buffer, boost::asio::ip::basic_endpoint<boost::asio::ip::udp>&, boost::system::error_code&)’
make: *** [server.o] Error 1
是文檔錯誤還是我做錯了什麼? 編輯:不,我錯了...對不起,我有一個時刻...它被稱爲過度勞累!我現在半睡着了。我缺少標誌參數。