我正在开发一些服务器应用程序,它的框架是名为UeTcpServer
的QTcpServer
子类。服务器应用程序正常启动,当我在ueSlotTcpServerNewConnection()
中放置断点时,它通过以下方式连接到UeTcpServer
的newConnectionSignal
connect(this->ueTcpServer(),
SIGNAL(newConnection()),
this,
SLOT(ueSlotTcpServerNewConnection()));
然后使用Linux terminal
连接到服务器应用程序,断点在ueSlotTcpServerNewConnection()
插槽中激活:
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
。为什么?
https://stackoverflow.com/questions/38262402
复制相似问题