源码如下
- #include <QtCore/QCoreApplication>
- #include <QtNetwork/QAbstractSocket>
- #include <QtNetwork/QSslSocket>
- #include <QtNetwork/QSslCertificate>
- #include <QtNetwork/QSslCipher>
- #include <QDebug>
- int main(int argc, char *argv[])
- {
- QCoreApplication a(argc, argv);
- QSslSocket socket;
- socket.connectToHostEncrypted("http.example.com", 443);
- if (!socket.waitForEncrypted()) {
- qDebug() << socket.errorString();
- return false;
- }
- socket.write("GET / HTTP/1.0\r\n\r\n");
- while (socket.waitForReadyRead())
- qDebug() << socket.readAll().data();
- return a.exec();
- }
编译提示
D:/Qt/workspace/TCP_Test/main.cpp:13: error: `QSslSocket' was not declared in this scope
D:/Qt/workspace/TCP_Test/main.cpp:13: error: expected `;' before "socket1"
D:/Qt/workspace/TCP_Test/main.cpp:15: error: `socket1' was not declared in this scope
D:/Qt/workspace/TCP_Test/main.cpp:13: warning: unused variable 'QSslSocket'
明明里面有QSslSocket的头文件
希望高手解答下
[ 此帖被wan2004在2009-03-16 14:41重新编辑 ]