sklose
asked on
Using Winsock in a DLL
Hi,
I am trying to write a simple socket program for a C++ DLL. I am getting the errors
c:\program files\microsoft visual studio\vc98\include\winsoc k.h(520) : error C2011: 'linger' : 'struct' type redefinition
I have the following code to protect redefinition in all .h files:
#ifndef __WIN32_H
#define __WIN32_H
#include <winsock.h>
#include .....
#endif
I am also getting the following warnings. They seem very odd to me
c:\program files\microsoft visual studio\vc98\include\winsoc k.h(551) : warning C4005: 'FD_READ' : macro redefinition
c:\program files\microsoft visual studio\vc98\include\winsoc k2.h(598) : see previous definition of 'FD_READ'
I have the ws2_32.lib in the project-link tab
please help :)
Sonya Klose
I am trying to write a simple socket program for a C++ DLL. I am getting the errors
c:\program files\microsoft visual studio\vc98\include\winsoc
I have the following code to protect redefinition in all .h files:
#ifndef __WIN32_H
#define __WIN32_H
#include <winsock.h>
#include .....
#endif
I am also getting the following warnings. They seem very odd to me
c:\program files\microsoft visual studio\vc98\include\winsoc
c:\program files\microsoft visual studio\vc98\include\winsoc
I have the ws2_32.lib in the project-link tab
please help :)
Sonya Klose
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thankyou!!!!
ASKER
It works now!
windows.h sure does include winsock.h
All I had to do was replace winsock.h with windows.h and presto it work!
Thanks a million
windows.h sure does include winsock.h
All I had to do was replace winsock.h with windows.h and presto it work!
Thanks a million
I think that, the problem mentioned by you is occurring because, somewhere you
are including both WINSOCK.H and WINSOCK2.H . Only one of them can be included.
#include <WINSOCK.H>
#include <WINSOCK.H>
will work fine , but
#include <WINSOCK.H> //this could be be //in some other header file , and that //file is getting included here
#include <WINSOCK2.H>
will lead to errors similar to what you have stated.
Hope this helps.