Using sys/socket.h functions on windows

You have two options:

  1. Use Cygwin (Unix emulation library).
  2. Port to Winsock (Windows standard library).

Cygwin: lets you compile your Unix sources mostly untouched, but ties you to the Cygwin emulation library. This have two implications: general performance -no only network- will probably be less than optimal; and the target environment must have (at run time) the Cygwin DLL installed.

Winsock: this requires you to replace sys/socket.h (BSD sockets library, UNIX standard for the TCP/IP stack) with winsock2.h, and rewrite some parts of the code – not much, but some.

Some related questions with valuable info:

Differences between winsock and BSD socket implementations

Some Issues About Cygwin[Linux in Windows] (socket,thread,other programming and shell issues)

Examples for Winsock?

Leave a Comment