发布时间:2023-06-05 16:00
网络编程初始化类
#include
#pragma comment(lib, "ws2_32.lib")
class CInitSock
{
public:
CInitSock(BYTE minorVer=2, BYTE majorVer=2)
{
WORD wVersionRequested = MAKEWORD(minorVer, majorVer);
WSADATA wsaData;
if (0 != ::WSAStartup(wVersionRequested, &wsaData))
{
exit(0);
}
}
~CInitSock()
{
::WSACleanup();
}
};