本文整理汇总了C++中TcpServer::setSocketDescriptor方法的典型用法代码示例。如果您正苦于以下问题:C++ TcpServer::setSocketDescriptor方法的具体用法?C++ TcpServer::setSocketDescriptor怎么用?C++ TcpServer::setSocketDescriptor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TcpServer
的用法示例。
在下文中一共展示了TcpServer::setSocketDescriptor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TcpSslServer
TcpServer *TcpServerBalancer::createServer(CWsgiEngine *engine)
{
TcpServer *server;
if (m_sslConfiguration) {
#ifndef QT_NO_SSL
auto sslServer = new TcpSslServer(m_serverName, m_protocol, m_wsgi, engine);
sslServer->setSslConfiguration(*m_sslConfiguration);
server = sslServer;
#endif //QT_NO_SSL
} else {
server = new TcpServer(m_serverName, m_protocol, m_wsgi, engine);
}
connect(engine, &CWsgiEngine::shutdown, server, &TcpServer::shutdown);
if (m_balancer) {
connect(engine, &CWsgiEngine::started, this, [=] () {
m_servers.push_back(server);
resumeAccepting();
}, Qt::QueuedConnection);
connect(server, &TcpServer::createConnection, server, &TcpServer::incomingConnection, Qt::QueuedConnection);
} else {
#ifdef Q_OS_LINUX
if (m_wsgi->reusePort()) {
connect(engine, &CWsgiEngine::started, this, [=] () {
int socket = listenReuse(m_address, m_port, true);
if (!server->setSocketDescriptor(socket)) {
qFatal("Failed to set server socket descriptor, reuse-port");
}
}, Qt::DirectConnection);
return server;
}
#endif
if (server->setSocketDescriptor(socketDescriptor())) {
server->pauseAccepting();
connect(engine, &CWsgiEngine::started, server, &TcpServer::resumeAccepting, Qt::DirectConnection);
} else {
qFatal("Failed to set server socket descriptor");
}
}
return server;
}