最近在开发im服务器 需要大并发链接 QT默认的是使用select模型的 这种轮询方式非常慢 在高并发连接 我们需要epoll才能发挥linux服务器的性能 而且使用简单 整个服务端代码架构无需修改 直接可以使用
只要在 main文件添加:
int main int argc char argv[]
{
#ifdef Q OS LINUX
QCoreApplication::setEventDispatcher new EventDispatcherLibEvent ;
qInstallMessageHandler customMessageHandler ;
#endif
QCoreApplication a argc argv ;
auto ser new ConfigServer;
ser >startServer ;
return a exec ;
}
在 pro文件添加
linux{
LIBS + levent core
SOURCES + common eventdispatcher libevent eventdispatcher libevent cpp
common eventdispatcher libevent eventdispatcher libevent config cpp
common eventdispatcher libevent eventdispatcher libevent p cpp
common eventdispatcher libevent socknot p cpp
common eventdispatcher libevent tco eventfd cpp
common eventdispatcher libevent tco pipe cpp
common eventdispatcher libevent tco cpp
common eventdispatcher libevent timers p cpp
HEADERS + common eventdispatcher libevent common h
common eventdispatcher libevent eventdispatcher libevent h
common eventdispatcher libevent eventdispatcher libevent config h
common eventdispatcher libevent eventdispatcher libevent config p h
common eventdispatcher libevent eventdispatcher libevent p h
common eventdispatcher libevent libevent2 emul h
common eventdispatcher libevent qt4compat h
common eventdispatcher libevent tco h
common eventdispatcher libevent wsainit h
}
可以直接跨平台了使用了
csdn博客:http: blog csdn net rushroom">最近在开发im服务器 需要大并发链接 QT默认的是使用select模型的 这种轮询方式非常慢 在高并发连接 我们需要epoll才能发挥linux服务器的性能 而且使用简单 整个服务端代码架构无需修改 直接可以使用
只要在 main文件添加:
[更多]