If I just do
if((tempSocket = SDLNet_TCP_Accept(sd)) > 0)
then I can accept sockets.But if I try to actually check the socket set as I have it below it will let me accept one client.
Then once I have a client connected it won't say the socket set has activity when a client tries to connect until the first one disconnects.
while(cont)
{
int numReady = SDLNet_CheckSockets(serverSet,0);
if(numReady < 0)
log("Error checking server socket set.");
else if(numReady > 0)
{
if(SDLNet_SocketReady(sd))
{
tempSocket = SDLNet_TCP_Accept(sd);
if(tempSocket)
{
log("Connection accepted.");
int freeClient = findFreeClient();
if(freeClient != -1)
{
if(clients[freeClient].createClient(tempSocket))
{
log("Accepted client with ID " + istr(freeClient));
}
else
log("Could not create new client.");
tempSocket = NULL;
}
else
log("Had to reject client. Too many connections.");
}
else
log("Error accepting socket.");
}
else
log("Checked socket not ready.");
}
SDL_Delay(10);
}
Should I just check for accept sockets like above even though it throws an error with SDLNet_GetError() or is there a way around this. If it's relevant the sockets connecting are from the same IP. (localhost)