Hello There,

Can anyone help me figure out how to get Winsock and the Windows SDK working with Netbeans? I am using the latest version of both the SDK(6.1) and Netbeans (6.5). I have downloaded the SDK but I don't know how to get the libraries to link to Netbeans.

Thanks

Here is the code that I am using to test if it works:

//
// Test Winsock2
//
#define __USE_W32_SOCKETS
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <winsock2.h>


// main()
int main(int argc, char **argv)
{
    WSADATA wsaData;
    WORD wVersionRequested = MAKEWORD(2,0);
    int nRet;

    // Init WinSock
    nRet = WSAStartup(wVersionRequested, &wsaData);
    if (nRet)
    {
		fprintf(stderr,"\nError initializing WinSock\n");
		return -1;
    }

	// Check version
	if (wsaData.wVersion != wVersionRequested)
	{
		fprintf(stderr,"\nWinSock version not supported\n");
		return -1;
	}


	// Free WinSock
    WSACleanup();
    return 0;
}

right click on the project name, then select Properties at the bottom of the menu. In the Categories box select Linker, then on the right side click the button with "..." next to "Libraries" (near the bottom) , In the popup window select "Add Library" and there you can add ws2_32.a

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.