Best way to poll sockets?
I'm making a server emulator for an old mmo and would like to know the best way to poll sockets. At the moment i've got a class called SoxPoller that uses select. The code below is the class:
Code:
SoxPoller::SoxPoller()
{
FD_ZERO(&readSet);
FD_ZERO(&writeSet);
FD_ZERO(&errorSet);
range = 0;
options = 0;
}
void SoxPoller::AddSocket(const Socket& s, int options)
{
unsigned int socketId = s.GetSocket();
this->options |= options;
if(options & POLL_READ)
FD_SET(socketId, &readSet);
if(options & POLL_WRITE)
FD_SET(socketId, &writeSet);
if(options & POLL_ERROR)
FD_SET(socketId, &errorSet);
if(socketId > range)
range = socketId;
}
bool SoxPoller::IsSet(const Socket& s, int option)
{
unsigned int socketId = s.GetSocket();
if(option == POLL_READ)
return FD_ISSET(socketId, &readSet);
if(option == POLL_WRITE)
return FD_ISSET(socketId, &writeSet);
if(option == POLL_ERROR)
return FD_ISSET(socketId, &errorSet);
return false;
}
int SoxPoller::Poll(int timeOut)
{
struct timeval timev;
timev.tv_sec = 0;
timev.tv_usec = timeOut;
return select(range + 1, &readSet, &writeSet, &errorSet, (timeOut >= 0 ? &timev : NULL));
}
But i've read select can only do like 64 sockets at a time. Linux has a method called "poll" but it's not available on windows. I know windows has "async" sockets that uses events but i want the server to be cross platform. What's the best way i can poll these sockets?