Trouble checking virtual server(vps) connection with qt

70 views Asked by At

I want to enter in the program, ip, username and password of a virtual server(vps), and the program checks that the username and password are correct or not.

I used the following code

void MainWindow::test()
{
    QLoggingCategory::setFilterRules("qt.network.ssl.warning=false");
    QNetworkAccessManager* manager = new QNetworkAccessManager(this);
    QUrl url;
    url.setHost("xx.xxx.xx.xx");
    url.setPort(3389);
    url.setUserName("administrator");
    url.setPassword("xxxx");
    manager->get(QNetworkRequest(url));
    connect(manager,&QNetworkAccessManager::finished, this, &MainWindow::connFinished);
}

output:

QNetworkReply::NetworkError(ProtocolUnknownError)

please guide me

1

There are 1 answers

1
user3606329 On

If you only want to know, if the host is online: I would suggest you use connectToHost from QAbstractSocket Class. The RDP-Protocol is based on TCP/UDP according to Wikipedia and listens on 3389 (what you said in the comments.).

If the connection on TCP 3389 is successful, the host is online.

If you want to verify if the host is online and the authentication works you have to implement your own RDP-library such as FreeRDP, because Qt does not provide any core modules for RDP.