MFC CSocket vs. thread + CAsyncSocket
Posted on 2005-03-25
I am designing a server for networked card games with MFC. The server consists of a heirarchy of "servlets": each room will exist on a separate process, with a separate server socket, and an incoming and outgoing message queue. Each room consists of several tables, which may also be described this way.
Therefore, my abstraction contains a "ServerThread", which manages a (server) CAsyncSocket, toggling non-blocking IO when appropriate. The server thread would also pump messages to and from client sockets, and ocasionally respond to client messages. I am debating whether to also use CAsyncSockets for client sockets. It would obviously be difficult to manage the IO state for all client sockets. I think it would be much simpler to have a "ClientThread", which would use an ASyncSocket that always blocks (not sure if it would actually work otherwise). Is it worth it, or should I just use plain CSockets?
It should be noted that this server thread does not need a Windows message pump, as it only responds to socket messages.
Also, are there any good open-source MFC compatible ThreadPools and/or SocketPools out there?