41 lines
776 B
C
41 lines
776 B
C
|
#pragma once
|
||
|
#include "pub.h"
|
||
|
#include "md5.h"
|
||
|
#include "AES.h"
|
||
|
|
||
|
class SocketC
|
||
|
{
|
||
|
private:
|
||
|
|
||
|
struct MsgHead
|
||
|
{
|
||
|
int isStr = 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<VOID(char*, int)> Rfunc = NULL;
|
||
|
function<VOID()> Cfunc = NULL;
|
||
|
bool initSocket();
|
||
|
VOID Receive();
|
||
|
char* RecvBuff(char* buf, int& len, int& isStr);
|
||
|
|
||
|
|
||
|
public:
|
||
|
SocketC(int bufSize = 4096, int modo = 0);
|
||
|
~SocketC();
|
||
|
bool Connect(string IP, UINT Prot);
|
||
|
int SendData(const char* Date, int len, int isStr = 0);
|
||
|
BOOL SendStr(string str);
|
||
|
VOID SetRecvFunc(function<VOID(char*, int)> fun);
|
||
|
VOID SetCloseFunc(function<VOID()> fun);
|
||
|
void Close();
|
||
|
};
|