What is The Difference Between CSocket() and socket()? About MFC

To make things easier for cosing in Win32 API, MFC is created which wraps Win32 API in classes.

At the beginning i though MFC is there only to aid you making C/C++ GUI Application.

For example, CSocket() wraps the function socket(), printf() gets wrapped in another class, and so on. Why in MFC everything is wrapped into a class even though some parts don't really need to be wrapped, such as socket(), send(), etc.

I think MFC should only wrap GUI API for Windows, since the GUI part requires alot of coding such as keeping a track of messages loop & make sure about the which button is clicked, etc. So in my opinion, winsock API should not be wrapped, e.g. when a user clicks "connect" button, we should use connect() - the main API, not the wrapped one because this wouldn't really effect the user! CSocket() will do exact same thing socket() does. Thus, CSocket() will slower than socket().

Let me explain more, when you want to print a data to static box, you can't use printf(), you need to use a special CStatic class that prints out the text to a static text box. This makes sense, but creating a socket, just happens behind the seen, we do not create a socket and show it on screen! so we do not need a wrapper for it as the wrapper won't do anything new, it just wraps socket() inside CSocket(). Eventually, they both do samething, CSocket() might be slower too.

After all, i think we just need a wrapper that makes objects (Windows Forms) & handle them, such as CStatic. The rest should be coded as it is.

1. Any suggestions? am i right or wrong? why?
2. Can MFC be used with Delphi, C#, etc just like Win API? or Its been made for C++ specifically?

I hope you are getting my point. I apologize for making my explanation long, i'm just trying to reach you what goes in my mind. Please answer me in an easy fashion if you don't mind. I already have enough confusion
hey f ben isaac,
(first,my mother language is not english. please forgive me.)
1. Any suggestions? am i right or wrong? why?
Let me tell you. In coder level, your idea may be easiser to be fit for finishing some coding project ASAP. However, in design level, it's too bad.
if you have free time ,you'd better to read some book about OOP. And then, you will find out the answer by yourself.^_^

2. Can MFC be used with Delphi, C#, etc just like Win API? or Its been made for C++ specifically

yes, it just been made for VC specifically.
THANKS
MFC was done to create a common object system and to hide details making Win programming easier/faster. The original thought was that all objects are derived from a common class and also to give an app skeleton to work on. When implementing programs you derive your own objects from the MFC classes to add custom properties/behavior. So it makes sense having other classes than GUI objects like CSocket.

MFC is written in C++ and has C++ headers etc that need to be included as it is very macro oriented, lot of the definitions are done using macros.

1. wrong
2. C++ yes.

Topic archived. No new replies allowed.