fatal error: netinet/in.h: No such file or directory

Viewed 11580
1 Answers

For the socket stuff on Windows you need #include <winsock2.h> and you will also need to link with -lws2_32.

In the beginning of your program you will also need to initialize the library like this:

static WSADATA wsaData;
int wsaerr = WSAStartup(MAKEWORD(2, 0), &wsaData);
if (wsaerr)
  exit(1);

and clean before exiting like this:

WSACleanup();

For the rest most basic networking functions are the same as on *nix platforms, except for close() which doesn't work on sockets, so you will need to do closesocket() instead.

Related