I finally got winsock code to compile by compiling it as a windows project.. as opposed to c++ source.
I successfully added the llibws2_32.a by going to Project-> Project Options -> parameters, but after compilation execution is terminated.. why???
using namespace std;
LPDWORD bufferlength = 0;
if(WSAStartup(MAKEWORD(2,2), &wsd) != 0)
cout << "\n\aWSAStartup failed.";
cout << "\n\nUsing winsock version " << wsd.wVersion;
//This call will fail, but will return the correct buffer size
WSAEnumProtocols(NULL, NULL, bufferlength);
//Allocate the correct buffer size of WSAPROTOCOL_INFO structures
proto = new WSAPROTOCOL_INFO[*bufferlength];
//Populate an array of system protocols
WSAEnumProtocols(NULL, proto, bufferlength);
//Step through the array and view some system supported protocol information
for(int i=0; i<*bufferlength; i++)
cout << "\n\n\nVersion: " << proto[i].iVersion;
cout << "\nAddress Family: " << proto[i].iAddressFamily;
cout << "\nMax Sockets: " << proto[i].iMaxSockAddr;
cout << "\nMin Sockets: " << proto[i].iMinSockAddr;
cout << "\nProtocol: " << proto[i].szProtocol;
cout << "Press [ENTER] to continue...";
Compiler: Default compiler
Building Makefile: "F:\Dev-Cpp\Makefile.win"
make.exe -f "F:\Dev-Cpp\Makefile.win" all
make.exe: Nothing to be done for `all'.