Results 1 to 5 of 5

Thread: A question about a code

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2011
    Posts
    195
    Thanks
    49
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default A question about a code

    Hi,
    I found this code at a linux program. It is a client - server application and this is a part of the client.
    The communication is ssl encrypted.

    Qt Code:
    1. Client::Client(QString host,long port,bool fs)
    2. {
    3. /*if(!serverConnection)*/ serverConnection = new QSslSocket(this);
    4.  
    5. serverConnection -> setPeerVerifyMode(QSslSocket::QueryPeer);
    6. serverConnection -> setLocalCertificate("mycert.pem");
    7. serverConnection -> setPrivateKey("mycert.pem");
    8. serverConnection -> connectToHostEncrypted( host, port);
    9. peerPort = port;
    10. connected=0;
    11. fileSend=fs;
    12. connect(serverConnection, SIGNAL(encrypted()), SLOT(connectionAccepted()));
    13. connect(serverConnection,SIGNAL(stateChanged(QAbstractSocket::SocketState)),this, SLOT(socketStateChanged(QAbstractSocket::SocketState)));
    14. connect(serverConnection, SIGNAL(readyRead()), this, SLOT(readDataFromServer()));
    15. connect(serverConnection, SIGNAL(disconnected()), serverConnection, SLOT(deleteLater()));
    16. connect(serverConnection, SIGNAL(sslErrors(QList<QSslError>)),SLOT(sslErrors(QList<QSslError>)) );
    17. }
    To copy to clipboard, switch view to plain text mode 
    The programmer calls serverConnection -> connectToHostEncrypted( host, port); and after that he connects the signal encrypted() to the slot connectionAccepted();
    But it should be connected first, shouldn't it?
    Last edited by Qiieha; 13th January 2012 at 12:48.

Similar Threads

  1. Replies: 2
    Last Post: 9th January 2010, 16:41
  2. Qftp example code question ... hello everyone
    By jrandles in forum Qt Programming
    Replies: 1
    Last Post: 8th February 2008, 21:57
  3. Question about qvector.h code of Qt 4
    By karapas in forum Qt Programming
    Replies: 6
    Last Post: 29th August 2007, 12:27
  4. Example code and metaObject question
    By bruccutler in forum Newbie
    Replies: 1
    Last Post: 12th January 2007, 18:34
  5. a question conerning code in main.cpp
    By nass in forum Qt Programming
    Replies: 1
    Last Post: 19th September 2006, 16:55

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.