void MemoryLeakTest::pbStartClicked(){ TCPServer * serv = new TCPServer(); connect(serv, SIGNAL(newConnection(qint32)), this, SLOT(newClient(qint32))); if (serv->listen(QHostAddress::Any, 2000)) qDebug()<<"listening";}void MemoryLeakTest::newClient(qint32 socketDescriptor){ client = new QSslSocket(); connect(client, SIGNAL(readyRead()), this, SLOT(canRead())); connect(client, SIGNAL(sslErrors(QList<QSslError>)), client, SLOT(ignoreSslErrors())); client->setSocketDescriptor(socketDescriptor); client->setPrivateKey("C://defaultKeySpiral.key"); client->setLocalCertificate("C://defaultCertSpiral.crt"); client->startServerEncryption(); qDebug()<<"encrypted "<<(client->waitForEncrypted(3000) ? "true" : client->errorString());}void MemoryLeakTest::canRead(){ client->readAll();}
void ThreadClient::run(){ QSslSocket * client = new QSslSocket(); connect(client, SIGNAL(sslErrors(QList<QSslError>)), client, SLOT(ignoreSslErrors())); client->connectToHost("127.0.0.1", 2000); qDebug()<<"Connected "<<client->waitForConnected(3000); client->setPrivateKey("C://defaultKeyAgent.key"); client->setLocalCertificate("C://defaultCertAgent.crt"); client->startClientEncryption(); if (client->waitForEncrypted(3000)) { QString mes; mes.append("sdsds"); for (int i=0;i<500000;++i) { client->write(mes.toAscii()); client->waitForBytesWritten(3000); } } else qDebug()<<client->errorString(); qDebug()<<"finished";}
qint64 QSslSocket::writeData(const char *data, qint64 len){ Q_D(QSslSocket);#ifdef QSSLSOCKET_DEBUG qDebug() << "QSslSocket::writeData(" << (void *)data << ',' << len << ')';#endif if (d->mode == UnencryptedMode && !d->autoStartHandshake) return d->plainSocket->write(data, len); char *writePtr = d->writeBuffer.reserve(len); ::memcpy(writePtr, data, len); // make sure we flush to the plain socket's buffer QMetaObject::invokeMethod(this, "_q_flushWriteBuffer", Qt::QueuedConnection); return len;}
if (d->mode == UnencryptedMode && !d->autoStartHandshake) return d->plainSocket->write(data, len);
void ThreadClient::run(){ QSslSocket * client = new QSslSocket(); connect(client, SIGNAL(sslErrors(QList<QSslError>)), client, SLOT(ignoreSslErrors())); connect(client, SIGNAL(encryptedBytesWritten(qint64)), this, SLOT(bytesWritten(qint64))); client->connectToHost("127.0.0.1", 2000); emit toLog(QString("Connected ") + (client->waitForConnected(3000) ? "true" : "false")); client->setPrivateKey("C://defaultKeyAgent.key"); client->setLocalCertificate("C://defaultCertAgent.crt"); client->startClientEncryption(); if (client->waitForEncrypted(30000)) { QString mes; mes.append("sdsds"); for (int i=0;i<500000;++i) { client->write(mes.toAscii()); QCoreApplication::processEvents(); client->waitForBytesWritten(3000); } } else emit toLog(client->errorString()); emit toLog("finished");}