Game Development Reference
In-Depth Information
if ( handleInput
&& !(pSock->m_deleteFlag&1) && FD_ISSET(pSock->m_sock, &inp_set))
{
pSock->VHandleInput();
}
}
}
unsigned int timeNow = timeGetTime();
// handle deleting any sockets
SocketList::iterator i = m_SockList.begin();
while (i != m_SockList.end())
{
pSock = *i;
if (pSock->m_timeOut && pSock->m_timeOut < timeNow)
pSock->VTimeOut();
if (pSock->m_deleteFlag&1)
{
switch (pSock->m_deleteFlag)
{
case 1:
g_pSocketManager->RemoveSocket(pSock);
i = m_SockList.begin();
break;
case 3:
pSock->m_deleteFlag = 2;
if (pSock->m_sock != INVALID_SOCKET)
{
closesocket(pSock->m_sock);
pSock->m_sock = INVALID_SOCKET;
}
break;
}
}
i++;
}
}
Notice the liberal use of FD_ZERO , FD_SET , and FD_ISSET . These are accessors to
the fd_set structures that are sent into the select() method and store the results.
This method
s job is to poll all the sockets you send into it for input, output, and
exceptions. The socket list is iterated three times in this method, which may seem
'
Search WWH ::




Custom Search