提交 b62314ae 编写于 作者: X xuchi

在不同系统下选择最佳网络通信模型

上级 85d05359
#ifndef _EasyServerMgr_hpp_
#define _EasyServerMgr_hpp_
// 在不同操作系统下面选择最佳网络通信模型
#if _WIN32 // windows系统下面会定义此宏
#include "TcpIocpServer.hpp" // using iocp, only windows.
#elif __linux__ // 在linux系统下面会定义此宏
#include "TcpEpollServer.hpp" // using epoll, only linux.
#else
#include "TcpSelectServer.hpp" // using select, both linux and windows. and other sys.
#endif
namespace doyou {
namespace io {
#if _WIN32
typedef TcpIocpServer TcpServerMgr;
#elif __linux__
typedef TcpEpollServer TcpServerMgr;
#else
typedef TcpSelectServer TcpServerMgr;
#endif
} // namespace io
} // namespace doyou
#endif // _EasyServerMgr_hpp_
......@@ -2,16 +2,13 @@
#include "Log.hpp"
#include "Config.hpp"
//#include "TcpSelectServer.hpp"
//#include "TcpEpollServer.hpp"
#include "TcpIocpServer.hpp" // 在windows系统下面首选iocp网络模型
#include "TcpServerMgr.hpp"
using namespace doyou::io; // 命名空间
// 可使用服务模型(三选一):1-TcpSelectServer 2-TcpEpollServer 3-TcpIocpServer
class MyServer : public TcpIocpServer
class MyServer : public TcpServerMgr
{
public:
......
......@@ -94,6 +94,7 @@
<ClInclude Include="..\Depends\include\TcpSelectClient.hpp" />
<ClInclude Include="..\Depends\include\TcpSelectServer.hpp" />
<ClInclude Include="..\Depends\include\TcpServer.hpp" />
<ClInclude Include="..\Depends\include\TcpServerMgr.hpp" />
<ClInclude Include="..\Depends\include\Thread.hpp" />
<ClInclude Include="..\Depends\include\TimeStamp.hpp" />
</ItemGroup>
......
......@@ -102,5 +102,8 @@
<ClInclude Include="..\Depends\include\TimeStamp.hpp">
<Filter>源文件</Filter>
</ClInclude>
<ClInclude Include="..\Depends\include\TcpServerMgr.hpp">
<Filter>源文件</Filter>
</ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册