• <menu id="w2i4a"></menu>
  • 首頁 > 慧問 > 頻道

    QTcpServer監(jiān)聽客戶端一段時(shí)間后,client斷開再連接,接收不到信號(hào)問題

    發(fā)表于2019-05-10 回復(fù):0 查看:7530  |  
    QTcpServer 監(jiān)聽幾個(gè)客戶端一段時(shí)間后,client退出,并觸發(fā)disconnected信號(hào),但是時(shí)間長,就會(huì)出現(xiàn)新的client 顯示連接上,但是Server沒有接收到信號(hào),QTimer也被堵塞,這種情況如何避免? 只能把監(jiān)聽的client分線程處理? 下面是接入Client并初始化。 <pre class='brush: cpp'>void QGHTcpServer::incomingConnection(int socketDescriptor) { QTcpSocket *pSock = new QTcpSocket(this); if (!pSock->setSocketDescriptor(socketDescriptor)) { emit evt_SocketError(pSock,pSock->error()); return; }else{ connect(pSock, SIGNAL(readyRead()),this, SLOT(new_data_recieved())); connect(pSock, SIGNAL(disconnected()),this,SLOT(client_closed())); connect(pSock, SIGNAL(error(QAbstractSocket::SocketError)),this, SLOT(displayError(QAbstractSocket::SocketError))); connect(pSock, SIGNAL(bytesWritten(qint64)), this, SLOT(some_data_sended(qint64))); m_clientList[pSock] = 0; emit evt_NewClientConnected(pSock); } }</pre>
    0個(gè)回答

    打破零回復(fù)...

    回復(fù)

    登錄 慧都網(wǎng)發(fā)表評(píng)論

    掃碼咨詢


    添加微信 立即咨詢

    電話咨詢

    客服熱線
    023-68661681

    TOP
    三级成人熟女影院,欧美午夜成人精品视频,亚洲国产成人乱色在线观看,色中色成人论坛 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();