首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >QTcpServer::hadPendingConnections()在新连接时返回false

QTcpServer::hadPendingConnections()在新连接时返回false
EN

Stack Overflow用户
提问于 2016-07-08 16:42:04
回答 0查看 451关注 0票数 0

我正在开发一些服务器应用程序,它的框架是名为UeTcpServerQTcpServer子类。服务器应用程序正常启动,当我在ueSlotTcpServerNewConnection()中放置断点时,它通过以下方式连接到UeTcpServernewConnectionSignal

代码语言:javascript
运行
复制
connect(this->ueTcpServer(),
        SIGNAL(newConnection()),
        this,
        SLOT(ueSlotTcpServerNewConnection()));

然后使用Linux terminal连接到服务器应用程序,断点在ueSlotTcpServerNewConnection()插槽中激活:

代码语言:javascript
运行
复制
void UeMainWindow::ueSlotTcpServerNewConnection()
{
    if(this->ueTcpServer()->hasPendingConnections())
    {
        QTcpSocket* incomingSocket=this->ueTcpServer()->nextPendingConnection();

        this->ueSlotAddEventInfoLog(0,
                                    tr("New incoming connection from host")
                                    .append(" ")
                                    //.append(this->ueTcpServer()->nextPendingConnection()->peerAddress().toString())
                                    .append(incomingSocket->peerName())
                                    .append(" ")
                                    .append(tr("with IP address"))
                                    .append(" ")
                                    .append(incomingSocket->peerAddress().toString())
                                    .append(" ")
                                    .append(tr("using port"))
                                    .append(" ")
                                    //.append(this->ueTcpServer()->nextPendingConnection()->peerPort()));
                                    .append(QString::number(incomingSocket->peerPort())));
    }   // if
}   // ueSlotTcpServerNewConnection

但是,this->ueTcpServer()->hasPendingConnection()返回false。为什么?

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38262402

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档