TFTP Download (cURL)



  • Guten Tag,
    ich habe folgendes Problem:

    Ich möchte die Datei "test.txt" auf dem TFTP-Server "192.168.0.2" runterladen und wiederrum als "test.txt" speichern.

    #include <QtCore/QCoreApplication>
    #include "curl.h"
    #include <QDebug>
    
    int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);
        CURL *curl;
        CURLcode res;
    
        curl = curl_easy_init();
        if(curl) {
          curl_easy_setopt(curl, CURLOPT_TFTP_BLKSIZE,
                            512);
          curl_easy_setopt(curl, CURLOPT_URL,
                           "tftp://192.168.0.2/test.txt");
    
          FILE *file = fopen("test.txt", "w");
          if(!file)
            return -1;
    
          curl_easy_setopt(curl, CURLOPT_WRITEDATA, file);
    
          curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
    
          res = curl_easy_perform(curl);
          curl_easy_cleanup(curl);
       }
    }
    

    Ich erhalte folgende Ausgabe:

    * About to connect() to 192.168.0.2 port 69 (#0)
    *   Trying 192.168.0.2... * connected
    * getpeername() failed with errno 10057: Socket is not connected
    * Connected to 192.168.0.2 (192.168.0.2) port 69 (#0)
    * set timeouts for state 0; Total 300, retry 6 maxtry 50
    

    Leider gibt es für eine TFTP-Datenübertragung via. cURL-Library keine Examples bzw. Dokumentationen.
    Könnt ihr mir vielleicht weiterhelfen?

    Vielen Dank schonmal für eure Beiträge

    LG,
    weilay


Anmelden zum Antworten