简体   繁体   中英

Can QSslSocket be used immediately after startServerEncryption()?

After I've called QSslSocket::startServerEncryption() , can I proceed to immediately use the socket as an ordinary QTcpSocket, reading and writing data from it, or do I need to call waitForStartEncrypted() before using it?

socket->startServerEncryption();
socket->waitForEncrypted(); // <==== Is this line necessary?
socket->write(data);
QByteArray response = socket->read();

You can start to use it immediately. The data will be buffered and sent later. Note that you can't read any data from it yet, since none will have arrived. The actual connection and handshake will not occur until you enter the event loop.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM