37 lines
598 B
C
37 lines
598 B
C
|
#pragma once
|
|||
|
#include<iostream>
|
|||
|
#include <winsock2.h>
|
|||
|
#include <ws2tcpip.h>
|
|||
|
#include <thread>
|
|||
|
#include <map>
|
|||
|
#include <mutex>
|
|||
|
#include <list>
|
|||
|
|
|||
|
|
|||
|
#pragma comment(lib,"ws2_32.lib")
|
|||
|
using namespace std;
|
|||
|
|
|||
|
class SocketC
|
|||
|
{
|
|||
|
public:
|
|||
|
struct MsgInfo
|
|||
|
{
|
|||
|
int len = 0; //<2F><><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
|||
|
char buff[2048] = {0}; //<2F><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
|
|||
|
};
|
|||
|
private:
|
|||
|
SOCKET sclient = 0;
|
|||
|
std::list<MsgInfo*>msgList;
|
|||
|
BOOL state = 0;
|
|||
|
std::thread rec;
|
|||
|
std::mutex msgLock;
|
|||
|
bool initSocket();
|
|||
|
VOID Receive();
|
|||
|
public:
|
|||
|
~SocketC();
|
|||
|
bool Connect(string IP, UINT Prot);
|
|||
|
int Send(const char* Date, int len);
|
|||
|
MsgInfo* GetMsg();
|
|||
|
void Close();
|
|||
|
};
|