IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Qt Discussion :

QFtp qui ne veut pas lire la réponse


Sujet :

Qt

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éprouvé Avatar de uriotcea
    Homme Profil pro
    Ingénieur / physicien
    Inscrit en
    Septembre 2003
    Messages
    1 301
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur / physicien
    Secteur : Service public

    Informations forums :
    Inscription : Septembre 2003
    Messages : 1 301
    Par défaut QFtp qui ne veut pas lire la réponse
    Bonjour,

    J'ai ecrit un serveurFTp qui envoie une chaine correspond à l'OS quand on lui envoie la command ""GETOS", je l'ai testé avec un client ftp ecrit avec INDY (borlandc++)
    Avec QT j'ai une difficulté le code ci-dessous marche jusqu'a la command 'rawCommand', j'ai verifier que mon serveur la recevait bien et envoyé bien une chaine de caractere (ici ->"Win32"). Mais je n'arrive pas à la récuperer avec readAll. J'ai essayé read(..) , pareil.
    Ou je me trompe donc?
    Merci de votre aide

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
      ftp = new QFtp(this);
      ftp->connectToHost(host,port);
      ftp->login (user,passWord);
      ftp->rawCommand("GETOS");
      line=ftp->readAll();
      printf("data -> %s\n",line.data());

  2. #2
    yan
    yan est déconnecté
    Rédacteur
    Avatar de yan
    Homme Profil pro
    Ingénieur expert
    Inscrit en
    Mars 2004
    Messages
    10 035
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Ingénieur expert
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mars 2004
    Messages : 10 035
    Par défaut
    Salut.
    QFtp est asynchrone (si je me trompe pas)

    donc quand tu fait readAll, il n'as toujours pas reçu ce qu'il fallait.
    sert toi des signaux pour lire le résultat au bon moment

  3. #3
    Membre éprouvé Avatar de uriotcea
    Homme Profil pro
    Ingénieur / physicien
    Inscrit en
    Septembre 2003
    Messages
    1 301
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur / physicien
    Secteur : Service public

    Informations forums :
    Inscription : Septembre 2003
    Messages : 1 301
    Par défaut
    Oui je crois, mais j'ai egalement essayé avec une attente de quelques second avant le readAll. J'ai bien vérifié que le serveur envoyait bien la chaine

  4. #4
    yan
    yan est déconnecté
    Rédacteur
    Avatar de yan
    Homme Profil pro
    Ingénieur expert
    Inscrit en
    Mars 2004
    Messages
    10 035
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Ingénieur expert
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mars 2004
    Messages : 10 035

  5. #5
    Membre éprouvé Avatar de uriotcea
    Homme Profil pro
    Ingénieur / physicien
    Inscrit en
    Septembre 2003
    Messages
    1 301
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur / physicien
    Secteur : Service public

    Informations forums :
    Inscription : Septembre 2003
    Messages : 1 301
    Par défaut
    Bonjour,

    J'ai cette fois comme suggéré dans un précédent message bien etudié la class QFtp et j'ai encore malgré tout un problem avec la commande rawCommand().
    Le code ci-dessous fonctionne bien jusqu'a cette commande qui démarre bien mais ne ce termine jamais.
    Au moment de la commande rawCommand("GETOS") mon serveur maison envoie (je l'ai verifié) la reponse "WIN32" mais je ne vais jamais ni dans 'commandFinished' ni dans 'rawCommandReply'.
    La sequence de ce code est la suivante:

    Command[1]: ConnectToHost
    state: HostLookup
    state: Connecting
    state: Connected
    end_Command[1]: NoError
    Command[2]: Login
    state: LoggedIn
    end_Command[2]: NoError
    Command[3]: RawCommand

    Je ne comprend vraiment pas pourquoi je reste bloqué à l'etape 3.
    Merci de votre aide


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
     
     
    class TW_ClientFTP : public QObject
    {
      Q_OBJECT
    public:
      TW_ClientFTP(QObject *parent);
      void getOS();
    signals:
      //void done();
    private slots:
      void processReply(int replycode, const QString &detail);
      void TW_ClientFTPdone(bool err);
      void SLOT_ftpCommandEnded(int id, bool error);
      void SLOT_newState(int state);
      void SLOT_ftpCommandStarted(int id);
    private:
      QFtp *ftp;
    };
     
     
    TW_ClientFTP::TW_ClientFTP(QObject *parent) : QObject(parent)
    {
      ftp = new QFtp(this);
      connect(ftp, SIGNAL(rawCommandReply(int, const QString &)),this, SLOT(processReply(int, const QString &)));
      connect(ftp, SIGNAL(done(bool)),this, SLOT(TW_ClientFTPdone(bool)));
      connect(ftp, SIGNAL(commandStarted(int)), this, SLOT(SLOT_ftpCommandStarted(int)));
      connect(ftp, SIGNAL(commandFinished(int, bool )), this, SLOT(SLOT_ftpCommandEnded(int , bool )));
      connect(ftp, SIGNAL(stateChanged(int)), this, SLOT(SLOT_newState(int)));
     
    }
    void TW_ClientFTP::SLOT_newState(int state)
    {
      char *State[]={"Unconnected","HostLookup","Connecting","Connected","LoggedIn","Closing"};
      printf("state: %s\n",State[state]);
    }
    void TW_ClientFTP::SLOT_ftpCommandStarted(int id)
    {
      char *cde[]={"None","SetTransferMode","SetProxy","ConnectToHost","Login","Close","List","Cd","Get","Put","Remove","Mkdir","Rmdir","Rename","RawCommand"};
      printf("Command[%d]: %s\n",id,cde[ftp->currentCommand()]);
    }
     
    void TW_ClientFTP::SLOT_ftpCommandEnded(int id, bool error)
    {
      char *err[]={"NoError","HostNotFound","ConnectionRefused","NotConnected","UnknownError"};
      printf("end_Command[%d]: %s\n",id,err[error]);
    }
     
    void TW_ClientFTP::TW_ClientFTPdone(bool err)
    {
      printf("Error : %s\n",ftp->errorString().toStdString().c_str());
      //emit done();
    }
     
    void TW_ClientFTP::processReply(int n, const QString &rep)
    {
      printf("Rep[%d] : %s\n",n,rep.toStdString().c_str());
    }
     
    void TW_ClientFTP::getOS()
    {
      ftp->clearPendingCommands();
      ftp->connectToHost(host,port);
      ftp->login (user,passWord);
      ftp->rawCommand("GETOS");
      ftp->close();
    }

  6. #6
    yan
    yan est déconnecté
    Rédacteur
    Avatar de yan
    Homme Profil pro
    Ingénieur expert
    Inscrit en
    Mars 2004
    Messages
    10 035
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Ingénieur expert
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mars 2004
    Messages : 10 035
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    ftp->rawCommand("GETOS");
    ftp->close();
    peut être à cause du close...

Discussions similaires

  1. [JScrollPane] qui ne veut pas se mettre en haut a gauche
    Par Cyber@l dans le forum AWT/Swing
    Réponses: 4
    Dernier message: 24/11/2006, 10h41
  2. [VB.NET]un formulaire qui ne veut pas se fermer
    Par josyde2006 dans le forum Windows Forms
    Réponses: 2
    Dernier message: 18/08/2006, 08h29
  3. requetes qui ne veut pas passer
    Par suya95 dans le forum Requêtes
    Réponses: 14
    Dernier message: 04/07/2006, 14h17
  4. JOptionPane qui ne veut pas se fermer!
    Par benthebest dans le forum AWT/Swing
    Réponses: 6
    Dernier message: 29/12/2005, 22h05
  5. un fichier qui ne veut pas être supprimé!!!!
    Par en_stage dans le forum Autres Logiciels
    Réponses: 4
    Dernier message: 22/10/2005, 01h08

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo