Fixed missing completion call issue. However, boost::asio now automatically closes the socket. This cannot be disabled. So the next step is to use the boost::asio socket class for the session and everywhere else.

This commit is contained in:
lotodore
2009-01-25 21:12:33 +00:00
parent 17377f5a6b
commit 3c820445c6
3 changed files with 11 additions and 12 deletions
+10 -10
View File
@@ -26,10 +26,10 @@
#include <cassert>
#include <boost/bind.hpp>
#include <boost/asio.hpp>
#include <boost/asio.hpp>
using namespace std;
using boost::asio::ip::tcp;
using boost::asio::ip::tcp;
#define SEND_ERROR_TIMEOUT_MSEC 20000
@@ -46,7 +46,6 @@ SenderThread::SendDataManager::HandleWrite(const boost::system::error_code& erro
SetCompleted(true);
}
SenderThread::SenderThread(SenderCallback &cb)
: m_callback(cb)
{
@@ -135,18 +134,19 @@ SenderThread::Main()
else
{
boost::shared_ptr<NetPacket> tmpPacket = tmpManager->list.front();
boost::asio::async_write(
*tmpManager->socket,
boost::asio::buffer(tmpPacket->GetRawData(),
tmpPacket->GetLen()),
boost::bind(&SendDataManager::HandleWrite, tmpManager,
boost::asio::placeholders::error));
tmpManager->SetWriteInProgress(true);
boost::asio::async_write(
*tmpManager->socket,
boost::asio::buffer(tmpPacket->GetRawData(),
tmpPacket->GetLen()),
boost::bind(&SendDataManager::HandleWrite, tmpManager,
boost::asio::placeholders::error));
tmpManager->SetWriteInProgress(true);
}
}
}
i = next;
}
m_ioService.run_one();
Msleep(SEND_TIMEOUT_MSEC);
}
}