Why you don't like mfc sockets AlexFM ? Is there any reason for that?
Vadivel Kumar
Main Topics
Browse All TopicsI 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?
Thanks,
Shawn Curry
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Using MFC socket classes hides internal implementation of sockets raw API and managing of worker threads required for this. This makes program non-portable, while sockets are supposed to work in any operating system. Personally, I don't like to use MFC serialization code with sockets. I prefer to have full control rather than rely on MFC support. But this is individual preference. You can write good program using CAsyncSocket class. For example, MFC HTTPSVR Sample is full-featured WEB server written using CAsyncSocket class. This proves that this class is quite good.
I prefer to use MFC only for Windows-related tasks. I don't like the following MFC classes:
1) Containers (it's better to use STL).
2) File operations (I am quite happy with CreateFile)
3) Sockets (I prefer socket API)
4) COM support (ATL is better).
I know that most MFC developers have the same opinion about STL and ATL. About sockets - I don't suggest you to follow my choice, you can decide this yourself.
Thank you for your input. I have learned a great deal about Microsoft's support for sockets and threads since first asking the question. I have elected not to use MFC; as the user interface will likely be written in Java, and I need slightly finer-grained control than MFC provides. I will definately need a ThreadPool, therefore I am designing my own Java-like sockets and concurrency APIs.
Thanks again,
Shawn
Business Accounts
Answer for Membership
by: AlexFMPosted on 2005-03-26 at 05:23:57ID: 13636061
CSocket class is not used in professional programs. Since this class is synchronous, it is used mostly by beginner programmers giving them simple interface which they can handle.
The choice is between using CAsyncSocket or socket API. I don't like MFC sockets support and prefer sockets API, but this is my personal opinion.