Removing old native socket stuff which is now unused (replaced by asio calls).

This commit is contained in:
lotodore
2009-06-16 22:00:07 +00:00
parent d45e41c963
commit 31dadd6fa2
19 changed files with 38 additions and 598 deletions
-70
View File
@@ -80,76 +80,6 @@ SessionManager::RemoveSession(SessionId session)
m_sessionMap.erase(session);
}
SessionWrapper
SessionManager::Select(unsigned timeoutMsec)
{
SessionWrapper retSession;
SOCKET maxSock = INVALID_SOCKET;
fd_set rdset;
FD_ZERO(&rdset);
{
boost::recursive_mutex::scoped_lock lock(m_sessionMapMutex);
SessionMap::iterator i = m_sessionMap.begin();
SessionMap::iterator end = m_sessionMap.end();
while (i != end)
{
// Collect all sockets.
SOCKET tmpSock = i->second.sessionData->GetSocket();
FD_SET(tmpSock, &rdset);
if (tmpSock > maxSock || maxSock == INVALID_SOCKET)
maxSock = tmpSock;
// Check if a packet is available.
if (!i->second.sessionData->GetReceiveBuffer().receivedPackets.empty())
{
retSession = i->second;
break;
}
++i;
}
}
if (!retSession.sessionData.get())
{
if (maxSock == INVALID_SOCKET)
{
Thread::Msleep(timeoutMsec); // just sleep if there is no session
}
else
{
// wait for data
struct timeval timeout;
timeout.tv_sec = timeoutMsec / 1000;
timeout.tv_usec = (timeoutMsec % 1000) * 1000;
int selectResult = select(maxSock + 1, &rdset, NULL, NULL, &timeout);
if (!IS_VALID_SELECT(selectResult))
{
throw ServerException(__FILE__, __LINE__, ERR_SOCK_SELECT_FAILED, SOCKET_ERRNO());
}
if (selectResult > 0) // one (or more) of the sockets is readable
{
// Check which socket is readable, return the first.
boost::recursive_mutex::scoped_lock lock(m_sessionMapMutex);
SessionMap::iterator i = m_sessionMap.begin();
SessionMap::iterator end = m_sessionMap.end();
while (i != end)
{
if (FD_ISSET(i->second.sessionData->GetSocket(), &rdset))
{
retSession = i->second;
break;
}
++i;
}
}
}
}
return retSession;
}
SessionWrapper
SessionManager::GetSessionById(SessionId id) const
{