void TCPServer::incomingConnection(int socketId) { ClientSocket *socket = new ClientSocket(this, m_widget, m_pool); socket->setSocketDescriptor(socketId); QString qstr; qstr += socket->peerAddress().toString(); qstr += ":"; qstr += QString::number(socket->peerPort()); qstr += " 连接上\n"; //m_textEdit->append(qstr); m_widget->writeToEditor(qstr); //m_textEdit->append(QString::fromLocal8Bit("获取CPU使用率失败").append(tr("\n"))); }
void AnonymousServer::incomingConnection(int socketDescriptor) { ClientSocket *clientSocket = new ClientSocket(this); if (clientSocket->setSocketDescriptor(socketDescriptor)) { peers.insert(clientSocket->peerAddress(), clientSocket); peerCount = peers.count(); clientSocket->setSlot(peerCount - 1); connect(clientSocket, SIGNAL(encrypted()), SLOT(encryptionReady())); connect(clientSocket, SIGNAL(messageReceived(QByteArray*)), SLOT(readyRead(QByteArray*))); connect(clientSocket, SIGNAL(disconnected()), SLOT(disconnected())); clientSocket->setLocalCertificate(tr("./certs/server.crt")); clientSocket->setPrivateKey(tr("./certs/server.key")); clientSocket->startServerEncryption(); emit connectionChange(peerCount); } else { delete clientSocket; } }