Programming sockets cygwin + Windows

I am trying to learn Socket programming on Windows and I am using cygwin for this. I found out that the required files needed for them were /usr/include/w32api/.

I took an example program from the network and tried to compile, but could not do it ... The code for it is

 #include <w32api/windows.h>
 #include <w32api/winsock.h>
 #include <stdio.h>
  int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow)
  {

       WORD sockVersion;
           WSADATA wsaData;
           int nret;

        sockVersion = MAKEWORD(1, 1);           // We'd like Winsock version 1.1

        // We begin by initializing Winsock

        WSAStartup(sockVersion, &wsaData);

       // rest part of code
   }

I compile it with gcc-3 in cygwin and get very strange errors .....

undefined reference to '_WSAStartup08' and many such errors...

I took the code from the training site and, therefore, would like to know what I am doing wrong, and how I should run the program.

Thank you so much.

edit ---------

I also tried using winsock2 instead of winsock.h, but the errors persist ...

+5
source share
1 answer

-lws2_32 must do it.

Cygwin , POSIX, winsock, . winsock, , , gcc-3 -mno-cygwin, Cygwin DLL . ( w32api/ #include.)

+6

All Articles