?? sockutils.h
字號:
#ifndef _SOCK_UTILS_H
#define _SOCK_UTILS_H
#include "winsock.h"
#pragma comment(lib,"wsock32.lib")
class socket_init
{
static long inited;
bool init_socket()
{
WSADATA wsa;
if( 0 != WSAStartup(MAKEWORD(1,1), &wsa) )
{
//printf("socket init error\n");
return false;
}
//printf("socket inited\n");
return true;
}
void uninit_socket()
{
WSACleanup();
}
public:
socket_init()
{
if( inited != 0 )
return;
InterlockedIncrement(&inited);
init_socket();
}
~socket_init()
{
if( 0 == InterlockedDecrement(&inited) )
uninit_socket();
}
};
long socket_init::inited = 0;
static socket_init socket_initialized;
#endif // _SOCK_UTILS_H
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -