QTcpServer和QTcpSocket的多客户端连接服务器的问题
我能打开多个客户端连接到服务器,并且返回
可是每个客户端只能连接一次!!!我很奇怪~为啥只能连接一次???
下面是我服务器主要代码:
QtcpServer:
void CServer::incomingConnection( int socketDescriptor ){ CServerThread *pThread = new CServerThread(socketDescriptor, this); connect(pThread, SIGNAL(finished()), this, SLOT(deleteLater())); pThread->start();}
void CServerThread::run(){ m_pClientConnection = new QTcpSocket(this); if (!m_pClientConnection->setSocketDescriptor(m_nSocketDescriptor)) { return; } connect(m_pClientConnection, SIGNAL(readyRead()), this, SLOT(slotGetXmlFromClient()), Qt::QueuedConnection); connect(m_pClientConnection, SIGNAL(disconnected()), this, SLOT(deleteLater())); this->exec();}