Compiling socket code for both Windows and Linux

1.3k Views Asked by At

I am writing a C++ program that uses sockets. I want my program to run on both Windows and Linux.

  • On Windows, I need to use:

Winsock2.h

  • On Linux, I need to use:

arpa/inet.h

How can I define my C++ program to run on different platforms, and how to include <arpa/inet.h> while I use Visual Studio on Windows?

Please give me an example!

0

There are 0 best solutions below