0

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

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by Ancient Dragon
0

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;
}
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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.