Client
::Client(QString host,
long port,
bool fs
) {
/*if(!serverConnection)*/ serverConnection = new QSslSocket(this);
serverConnection -> setPeerVerifyMode(QSslSocket::QueryPeer);
serverConnection -> setLocalCertificate("mycert.pem");
serverConnection -> setPrivateKey("mycert.pem");
serverConnection -> connectToHostEncrypted( host, port);
peerPort = port;
connected=0;
fileSend=fs;
connect(serverConnection, SIGNAL(encrypted()), SLOT(connectionAccepted()));
connect(serverConnection, SIGNAL(readyRead()), this, SLOT(readDataFromServer()));
connect(serverConnection, SIGNAL(disconnected()), serverConnection, SLOT(deleteLater()));
connect(serverConnection, SIGNAL(sslErrors(QList<QSslError>)),SLOT(sslErrors(QList<QSslError>)) );
}
Client::Client(QString host,long port,bool fs)
{
/*if(!serverConnection)*/ serverConnection = new QSslSocket(this);
serverConnection -> setPeerVerifyMode(QSslSocket::QueryPeer);
serverConnection -> setLocalCertificate("mycert.pem");
serverConnection -> setPrivateKey("mycert.pem");
serverConnection -> connectToHostEncrypted( host, port);
peerPort = port;
connected=0;
fileSend=fs;
connect(serverConnection, SIGNAL(encrypted()), SLOT(connectionAccepted()));
connect(serverConnection,SIGNAL(stateChanged(QAbstractSocket::SocketState)),this, SLOT(socketStateChanged(QAbstractSocket::SocketState)));
connect(serverConnection, SIGNAL(readyRead()), this, SLOT(readDataFromServer()));
connect(serverConnection, SIGNAL(disconnected()), serverConnection, SLOT(deleteLater()));
connect(serverConnection, SIGNAL(sslErrors(QList<QSslError>)),SLOT(sslErrors(QList<QSslError>)) );
}
To copy to clipboard, switch view to plain text mode
The programmer calls serverConnection -> connectToHostEncrypted( host, port); and after that he connects the signal encrypted() to the slot connectionAccepted();
Bookmarks