2 Star 14 Fork 4

gavingqf/anet

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
define.hpp 1.89 KB
一键复制 编辑 原始数据 按行查看 历史
gaoqingfeng 提交于 2024-09-09 08:18 . update
#pragma once
/*
* anet asio defining header.
*/
#include <functional>
#include "asio.hpp"
#include <assert.h>
#include <string>
#include <stdarg.h>
#include <stdio.h>
#include <ctime>
#include <vector>
#if defined(WIN32)
#pragma warning(disable:4996)
#endif
namespace anet {
namespace tcp {
class CConnection;
// sleep ms.
#define sleepMS(x) std::this_thread::sleep_for(std::chrono::milliseconds(x))
// sleep us.
#define sleepUS(x) std::this_thread::sleep_for(std::chrono::microseconds(x))
// asio library define.
typedef asio::io_context asioIOContext;
typedef asio::ip::tcp::acceptor asioAcceptor;
typedef asio::ip::tcp::socket asioSocket;
typedef asio::ip::tcp::endpoint asioEndPoint;
// CConnection share pointer.
typedef std::shared_ptr<CConnection> connSharePtr;
// CConnection weak pointer.
typedef std::weak_ptr<CConnection> connWeakPtr;
// async_connect error callback.
typedef std::function<void(const char* ip, unsigned short port, int err)> connectErrCallback;
// write buffer max size;
static int gMaxWriteBuffLength = 10 * 1024;
// max read buffer size;
static int gMaxReadBuffLength = 10 * 1024;
// max packet size.
static int gMaxPacketSize = 10 * 1024;
// listen blog size
static int gMaxListenBlog = 128;
// set max packet size
inline void setMaxPacketSize(int maxPacketSize) {
if (maxPacketSize > 0) {
gMaxPacketSize = maxPacketSize;
}
}
// set max listen blog size
inline void setMaxListenBlogSize(int blogSize) {
if (blogSize > 0) {
gMaxListenBlog = blogSize;
}
}
// set reading buffer size
inline void setReadBufferSize(int readBufferSize) {
if (readBufferSize > 0) {
gMaxReadBuffLength = readBufferSize;
}
}
// set writing buffer size
inline void setWriteBufferSize(int writeBufferSize) {
if (writeBufferSize > 0) {
gMaxWriteBuffLength = writeBufferSize;
}
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/gavingqf/anet.git
git@gitee.com:gavingqf/anet.git
gavingqf
anet
anet
master

搜索帮助