#pragma once #include #include #include #include #include #include #pragma comment(lib,"ws2_32.lib") using namespace std; class SocketC { private: struct MsgHead { int MyIndex = 0; int bufLen = 0; time_t tm = 0; char token[34] = { 0 }; }; char tmpBuf[10240] = { 0 }; int bufLen = 0; SOCKET sclient = 0; BOOL state = 0; std::thread rec; std::mutex msgLock; function Rfunc = NULL; function Cfunc = NULL; bool initSocket(); VOID Receive(); char* RecvBuff(char* buf, int& len); public: ~SocketC(); bool Connect(string IP, UINT Prot); int Send(const char* Date, int len); VOID SetRecvFunc(function fun); VOID SetCloseFunc(function fun); void Close(); };