Results 1 to 18 of 18

Thread: simple test connection

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2011
    Posts
    18
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: simple test connection

    this time i just like when we push the button he will go to fichier .txt and get the @ ip ligne by ligne and it will do the test
    i'm realy amateur in prog so plz help me

    Qt Code:
    1. void MainWindow::on_pushButton_clicked()
    2. {
    3.  
    4.  
    5. QFile fichier("/home/dousdou/idee.txt");
    6. fichier.open(QIODevice::ReadOnly);
    7. QString contenu = fichier.readAll();
    8. fichier.close();
    9.  
    10.  
    11.  
    12.  
    13. connect(mysocket,SIGNAL(connected()),this,SLOT(on_connected()));
    14. connect(mysocket,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(on_error(QAbstractSocket::SocketError)));
    15. mysocket->connectToHost(contenu, 22);
    16. if (mysocket->waitForConnected(1000))
    17. qDebug("Connected!");
    18.  
    19. };
    To copy to clipboard, switch view to plain text mode 

    but it doesn't work so where is the prb ?

  2. #2
    Join Date
    Oct 2010
    Location
    Belarus
    Posts
    71
    Thanks
    1
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Windows Maemo/MeeGo

    Default Re: simple test connection

    Show /home/dousdou/idee.txt file or attach it, plz
    Try read Qt documentation before ask stupid question.

  3. #3
    Join Date
    Mar 2011
    Posts
    18
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: simple test connection

    it's a file text

  4. #4
    Join Date
    Oct 2010
    Location
    Belarus
    Posts
    71
    Thanks
    1
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Windows Maemo/MeeGo

    Default Re: simple test connection

    Oh. idee.txt contain only one line with IP? Or several?

    For several line try some code:

    Qt Code:
    1. QStringList iplist;
    2. while (!file.atEnd())
    3. {
    4. iplist.append(file.readLine());
    5. }
    6. for(int i=0;i<iplist.count();++i)
    7. {
    8. ...
    9. mysocket->connectToHost(iplist.at(i), 22);
    10. ...
    11. }
    To copy to clipboard, switch view to plain text mode 

    So, you try find not firewalled SSH. it's dirty job.

    Аre you then ask as to help with software for password selection?
    Try read Qt documentation before ask stupid question.

  5. #5
    Join Date
    Mar 2011
    Posts
    18
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: simple test connection

    i push the button bute nothing is work (((((((((((((
    Qt Code:
    1. void MainWindow::on_pushButton_clicked()
    2. {
    3. QFile file("/home/dousdou/idee.txt");
    4. QStringList iplist;
    5. while (!file.atEnd())
    6. {
    7. iplist.append(file.readLine());
    8. }
    9.  
    10. for(int i=0;i<iplist.count();++i)
    11. {
    12.  
    13.  
    14. connect(mysocket,SIGNAL(connected()),this,SLOT(on_connected()));
    15. connect(mysocket,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(on_error(QAbstractSocket::SocketError)));
    16. mysocket->connectToHost(iplist.at(i), 22);
    17. if (mysocket->waitForConnected(1000))
    18. qDebug("Connected!");
    19. }
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Oct 2010
    Location
    Belarus
    Posts
    71
    Thanks
    1
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Windows Maemo/MeeGo

    Default Re: simple test connection

    You don't need use signal and slot if use waitForConnected

    Qt Code:
    1. void MainWindow::on_pushButton_clicked()
    2. {
    3. QFile file("/home/dousdou/idee.txt");
    4. file.open(QIODevice::ReadOnly);
    5. QStringList iplist;
    6. while (!file.atEnd())
    7. {
    8. iplist.append(file.readLine());
    9. }
    10.  
    11. for(int i=0;i<iplist.count();++i)
    12. {
    13. mysocket->connectToHost(iplist.at(i), 22);
    14. if (mysocket->waitForConnected(1000))
    15. qDebug("Connected!");
    16. else qDebug("Error!");
    17. }
    18. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by unit; 7th March 2011 at 16:10.
    Try read Qt documentation before ask stupid question.

  7. #7
    Join Date
    Mar 2011
    Posts
    18
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: simple test connection

    I have done what you told me to do but also it doesn't work i know it a simple application and i realy try maney thing but always the some prb it doesn't work so when i execute your code this is what he told me:
    Qt Code:
    1. Démarrage de /home/dousdou/test2-build-desktop/test2...
    2. QMetaObject::connectSlotsByName: No matching signal for on_connected()
    3. QMetaObject::connectSlotsByName: No matching signal for on_error(QAbstractSocket::SocketError)
    4. Error!
    5. Error!
    6. Error!
    7. Error!
    To copy to clipboard, switch view to plain text mode 

  8. #8
    Join Date
    Oct 2010
    Location
    Belarus
    Posts
    71
    Thanks
    1
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Windows Maemo/MeeGo

    Default Re: simple test connection

    You try to do copy/paste and change part of code without thinking about it. You should read some manuals and src of ready code, and learn what code is do. Try new attach with full code.

    I have next out:

    Qt Code:
    1. Cann't connect to ??10.110.10.22 with error Host not found
    2. Connected to 10.110.10.23
    3. Connected to 10.110.10.9
    4. Cann't connect to 10.110.10.105 with error Socket operation timed out
    5. Cann't connect to 10.110.10.86 with error Socket operation timed out
    To copy to clipboard, switch view to plain text mode 
    Attached Files Attached Files
    Try read Qt documentation before ask stupid question.

  9. #9
    Join Date
    Mar 2011
    Posts
    18
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: simple test connection

    i just modify the code like this :
    Qt Code:
    1. MainWindow::~MainWindow()
    2. {
    3. delete ui;
    4. delete mysocket;
    5. }
    6.  
    7. void MainWindow::on_pushButton_clicked()
    8. {
    9. QFile ipfile("/home/dousdou/tech-ip.txt");
    10. if(!ipfile.open(QIODevice::ReadOnly))
    11. {
    12. qDebug("Can't open file");
    13. return;
    14. }
    15. QStringList iplist;
    16. while (!ipfile.atEnd())
    17. {
    18. iplist.append(ipfile.readLine());
    19. }
    20. ipfile.close();
    21. for(int i=0;i<iplist.count();++i)
    22. {
    23. connect(mysocket,SIGNAL(connected()),this,SLOT(on_connected()));
    24. connect(mysocket,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(on_error(QAbstractSocket::SocketError)));
    25. mysocket->connectToHost(iplist.at(i), 22);
    26. }
    27. }
    28. void MainWindow::on_error(QAbstractSocket::SocketError socketError)
    29. {
    30. QMessageBox msgBox;
    31. msgBox.setText("Not connected " + QString::number(socketError));
    32. msgBox.exec();
    33. }
    34.  
    35. void MainWindow::on_connected()
    36. {
    37. QMessageBox msgBox;
    38. msgBox.setText("It's ok. Connected");
    39. msgBox.exec();
    40. mysocket->disconnectFromHost();
    41. }
    To copy to clipboard, switch view to plain text mode 
    and he show me this error:
    Qt Code:
    1. QMetaObject::connectSlotsByName: No matching signal for on_connected()
    2. QMetaObject::connectSlotsByName: No matching signal for on_error(QAbstractSocket::SocketError)
    3. QAbstractSocket::connectToHost() called when already looking up or connecting/connected to "10.20.24.157
    4. "
    5. QAbstractSocket::connectToHost() called when already looking up or connecting/connected to "192.168.1.5
    6. "
    7. QAbstractSocket::connectToHost() called when already looking up or connecting/connected to "10.20.24.155
    8. "
    To copy to clipboard, switch view to plain text mode 
    where is the rpb hier i know that's i'm not good in devlopment but plz i need your help i can work lonly and you are my last chance

  10. #10
    Join Date
    Oct 2010
    Location
    Belarus
    Posts
    71
    Thanks
    1
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Windows Maemo/MeeGo

    Default Re: simple test connection

    are you kidding me?

    Don't modify my CODE now. Only change path to file and try! Or tell me all your task and i try give you complete code. My Skype is unit_by
    Try read Qt documentation before ask stupid question.

Similar Threads

  1. test my QT application
    By anand_2861985 in forum Installation and Deployment
    Replies: 1
    Last Post: 24th November 2010, 10:32
  2. Replies: 1
    Last Post: 2nd April 2010, 06:42
  3. A.I. test. A.I. test.
    By Kumosan in forum General Discussion
    Replies: 3
    Last Post: 19th October 2007, 19:19

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.