I am compiling a project in Visual C++ 2010, but I have problems with some Winsock redefinitions.
First of all I get:
syntax error : identifier 'SOCKADDR_STORAGE'
But if I include winsock or winsock2 or ws2tcpip i get many errors like these:
error C2011: 'sockaddr' : 'struct' type redefinition
error C2011: 'WSAData' : 'struct' type redefinition
error C2011: 'linger' : 'struct' type redefinition
Your problem is that by including
Windows.h, you are also already includingwinsock.h. It is here your problem arises as includingwinsock2.horws2tcpip.hwill attempt to redefine some of the definitions inwinsock.hBy using
#define WIN32_LEAN_AND_MEANbefore yourWindows.hinclude you stop the compiler from including a lot of the extra stuff that comes withWindows.h