1 Star 0 Fork 0

gpro131 / USocket

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
KSock.h 736 Bytes
一键复制 编辑 原始数据 按行查看 历史
gpro131 提交于 2021-02-19 17:26 . add kocket
#pragma once
#include <iostream>
#include <string>
#include <chrono>
#include <functional>
#include <WinSock2.h>
#include <map>
#include "ikcp.h"
#include <vector>
#include <thread>
#pragma comment(lib,"ws2_32.lib")
using Buffer = std::vector<char>;
class KSock
{
public:
void Init(int kcpId,bool isReceiver = true);
void Send(char* data, int len);
void Recv(std::vector<char>& data);
void Release();
void KCPLoop();
UINT32 NOW()
{
std::chrono::steady_clock::time_point ts = std::chrono::steady_clock::now();
return ts.time_since_epoch().count();
}
SOCKET sock;
SOCKADDR_IN sockAddr;
std::string ip{ "127.0.0.1" };
int port{6868};
ikcpcb* kcp;
volatile bool isRunning;
Buffer RecvBuffer;
Buffer SendBuffer;
};
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/GProReat/usocket.git
git@gitee.com:GProReat/usocket.git
GProReat
usocket
USocket
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891