Skip to content

Instantly share code, notes, and snippets.

@RklAlx
Created September 27, 2013 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RklAlx/6727021 to your computer and use it in GitHub Desktop.
Save RklAlx/6727021 to your computer and use it in GitHub Desktop.
WSAStart Initialize WinsockDll
#include <winsock2.h>
#include <iostream>
using namespace std;
bool InitWinsockDLL()
{
WSADATA wsaData;
//
///* Use the MAKEWORD(lowbyte, highbyte) macro declared in Windef.h */
WORD wVersionRequested = MAKEWORD(2, 2);
int iResult = WSAStartup(wVersionRequested, &wsaData);
if (iResult != 0)
{
cout << "WSAStartup failed with error: "<< iResult << endl;
return false;
}
if (LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2)
{
/* Tell the user that we could not find a usable */
/* WinSock DLL. */
cout << "Could not find a usable version of Winsock.dll" << endl;
WSACleanup();
return false;
}
cout << "The Winsock 2.2 dll was found okay" << endl;
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment