From: Michael Wojcik on
Ulrich Eckhardt wrote:
> Rayne wrote:
>
>> 2) I had to define structures for IP, TCP and UDP myself for the
>> Windows program, since I can't find netinet/ip.h, netinet/tcp.h and
>> netinet/udp.h on Windows
>
> #include <winsock2.h>

winsock2.h has definitions for the IP, TCP, and UDP headers? I didn't
see them in a quick scan through that file, or those it includes.

> This unfortunately must come before <windows.h>, which in turn is included
> by things like <stdio.h>.

The problem is that windows.h, by default, includes winsock.h, which
conflicts with winsock2.h.

You can also define _WINSOCKAPI_ before including windows.h, to
suppress the contents of winsock.h - that's what winsock2.h does,
since of course it too includes windows.h (as do nearly all MS headers).

Or define WIN32_LEAN_AND_MEAN before including windows.h, if you don't
need any of the other things WIN32_LEAN_AND_MEAN suppresses:

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winsock2.h>

WIN32_LEAN_AND_MEAN prevents windows.h from including the following:

cderr.h
commdlg.h
dde.h
ddeml.h
dlgs.h
lzexpand.h
mmsystem.h
nb30.h
ole.h
ole2.h
rpc.h
shellapi.h
wincrypt.h
winefs.h
winperf.h
winscard.h
winsock.h
winspool.h

It significantly reduces how much namespace windows.h stomps on, as
well as letting you include winsock2.h unmolested.

--
Michael Wojcik
Micro Focus
Rhetoric & Writing, Michigan State University
From: Ulrich Eckhardt on
Michael Wojcik wrote:
> Ulrich Eckhardt wrote:
>> Rayne wrote:
>>
>>> 2) I had to define structures for IP, TCP and UDP myself for the
>>> Windows program, since I can't find netinet/ip.h, netinet/tcp.h and
>>> netinet/udp.h on Windows
>>
>> #include <winsock2.h>
>
> winsock2.h has definitions for the IP, TCP, and UDP headers?

Yes, it has definitions required to use TCP and UDP and some other
protocols. I don't know if it defines structures that define the respective
protocol's packet headers. It's not clear what exactly is needed.

;)

Uli

--
Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932