代碼如下:
呼叫連接成功之后執行boost::asio::async_read(socket,boost::asio:buffer(m_pPackBuffer,m_iGetLen),boost::asio::transfer_all(),boost::bind(&ClientSession::onRead,shared_from_this(),boost::asio::placeholders::error,boost::asio::placehoders::bytes_transferred));
每次回傳這個函式之后出錯,error.message()為: 錯誤代碼 10014,系統檢測到在一個呼叫中嘗試使用指標引數時的無效指標地址
void ClientSession::onRead(const boost::system::error_code &error,size_t bytes_transferred)
{
if(!error)
{
tcpClient->onMessage(m_pPackBuffer,(int)bytes_transferred);
boost::asio::async_read(socket,boost::asio:buffer(m_pPackBuffer,m_iGetLen),boost::asio::transfer_all(),boost::bind(&ClientSession::onRead,shared_from_this(),boost::asio::placeholders::error,boost::asio::placehoders::bytes_transferred));
}
else
{
handleProcException(error.message());
return;
}
}
請問是什么原因,怎么解決?
uj5u.com熱心網友回復:
在線等,第一個解決問題的得高分!uj5u.com熱心網友回復:
MSDN 的解釋WSAEFAULT 10014 Bad address.
The system detected an invalid pointer address in attempting to use a pointer argument of a call. This error occurs if an application passes an invalid pointer value, or if the length of the buffer is too small. For instance, if the length of an argument, which is a sockaddr structure, is smaller than the sizeof(sockaddr).
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/284159.html
標籤:網絡編程
下一篇:求助,word自定義宏設定快捷鍵