Created
September 27, 2013 11:04
-
-
Save RklAlx/6727021 to your computer and use it in GitHub Desktop.
WSAStart Initialize WinsockDll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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