//The WSAStartup function initiates use of the Winsock DLL by a process.
int WSAStartup(
__in WORD wVersionRequested,
__out LPWSADATA lpWSAData
);
//The WSACleanup function terminates use of the Winsock 2 DLL (Ws2_32.dll).
int WSACleanup(void);
#pragma once
#include <WinSock2.h>
#pragma comment(lib, "WS2_32")
class CWSAInit
{
public:
CWSAInit(BYTE minor_ver = 2, BYTE major_ver = 2);
~CWSAInit(void);
};
#include "WSAInit.h"
CWSAInit::CWSAInit(BYTE minor_ver, BYTE major_ver)
{
WSADATA wsa_data;
WORD sock_ver = MAKEWORD(minor_ver, major_ver);
if(::WSAStartup(sock_ver, &wsa_data) != 0) {
exit(0);
}
}
CWSAInit::~CWSAInit(void)
{
::WSACleanup();
}