Hi all, I'm a fresher to Visual Studio. I read some where MFC supports only winsock1. Is it true that MFC doesnt support winsock2?
Oddly yes it looks like it only uses 1.1.
You should have the source code with your VS install - you'll see in stdafx.h it includes winsock.h (not 2) and in sockcore.cpp there's code to initialise 1.1. VS2010's MFC is the same.
If you want to use winsock2 in your own code you'll have to include header before the MFC header in your project's stdafx.h so the declarations don't clash. Hopefully that won't break the AfxSocket interface though :-/
I am just quoting from here.
Changing:
#include <winsock.h>
To:
#include <winsock2.h>
doesn't make any difference other than able to use the winsock2 specific calls. You may be actually using winsock2 even if you are including only winsock.h. The actual difference is made whether you are linking to wsock32.lib (winsock 1.1) or ws2_32.lib (winsock 2.2). As I pointed out you have to use it. Simply by changing the header files or the lib where you are linked doesn't make any sort of difference in performace, efficiency, whatever. Actually you may loose compatibility with os that supports pure BSD socket calls when changing to ws2 while not using it.
Winsock2 came in for performace. The IO is managed by windows kernal (like overlapped io for instance). All your winsock 1.1 such as basic send/recv calls are directly mapped to the winsock 2.2 counterpart (WSASend/WSARecv).winsock2 is purely downward compatibe with winsock.