CSocket represents an actual socket, which you can connet with, send data to, and get it's buffer.
CSocketSet is a class that contains a group of CSockets. You can poll it every loop to get a list of sockets that have new data.
CSocketManager doesn't do much. It has functions for allocating and freeing a socket, and a way to map a SOCKET to a CSocket*.
CSocketServer is used for handling incomming connections. It can listen on several ports at once, and can be polled to see if there's a new connection.
Here's some example code (my test code). It listens for connections on port 23, and prints any data recieved to the console. When once socket becomes invalid (the client disconnected), it breaks out of the loop and cleans up.
int main(int argc, char** argv)
// Listen on port 23 //
// Loop //
// Accept new connections //
CSocket* pSock = theServer.GetNextConnection();
// Process pending //
// Get next socket with data waiting //
pSock = theSet.GetNextPending();
// Is socket valid? //
bBreak = true;
// Process buffer //
size_t nLen = pSock->ExtractBuffer(byBuff,255);
byBuff[nLen] = 0;
// Cleanup sockets //
for(DWORD i=0; i
I still need to profile it, I'm a bit worried that there might be some overhead of getting data from the reading threads into the actual socket buffers, but I don't think it'll be too bad.
And I still haven't finished bomberman. There's not much left to do at all, but I went out on Wednesday and spent most of Thursday recovering (Damn you GBP1/drink...). And now I have to go out to a friends birthday, so I doubt I'll be able to do any coding when I come in.