Results 1 to 20 of 57

Thread: QSslSocket vs QTcpSocket problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QSslSocket vs QTcpSocket problem

    Please make sure you understand the code I gave before using it. And never use code you do not understand.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. #2
    Join Date
    Mar 2011
    Posts
    53
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSslSocket vs QTcpSocket problem

    Please tell me before I will study hard your code, what do you mean by this line

    processData(data) (I can't figure out when I should pull out the data I need and for example write the in to the file)

    becouse I don't know how to refer to it, and maybe are there any signals I should take a closer look?
    Last edited by camol; 10th March 2011 at 13:04.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QSslSocket vs QTcpSocket problem

    processData() is a stub for your method for manipulating the data, the core of the server functionality. I don't know what your program is meant to do so I can't tell you what should be there.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Mar 2011
    Posts
    53
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSslSocket vs QTcpSocket problem

    basically I am sending files. The server after establishing connection is sending many many files one by one.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QSslSocket vs QTcpSocket problem

    So probably processData() should store the data on the disk or somewhere else.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Mar 2011
    Posts
    53
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSslSocket vs QTcpSocket problem

    But I have noticed that processData() is in if-condition, and as you can see from my "tests" the program is in that if-condition (you wrote) only once (at the first enter to the slot) and at that time data.size is 0.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QSslSocket vs QTcpSocket problem

    Did you adjust the sending side to the semantics of the receiving side or the other way round?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    Join Date
    Mar 2011
    Posts
    53
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSslSocket vs QTcpSocket problem

    It won't be enough if I just do sth like this?:
    Qt Code:
    1. QDataStream out(&block, QIODevice::WriteOnly);
    2. //serverfiles is a QStringList
    3. out << (out,serverfiles);
    4. serverSocket->write(block);
    To copy to clipboard, switch view to plain text mode 

    This code is in slot which starts thx to encrypted signal.

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QSslSocket vs QTcpSocket problem

    No, not really. You are streaming in a QStringList and reading back 4 bytes assembled into integer and an anonymous block of data. How do you expect it to work?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #10
    Join Date
    Mar 2011
    Posts
    53
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSslSocket vs QTcpSocket problem

    Becouse I still can't see how it should work this, I don't understand how to adjust the code at the server side(I am sending QSringList which has paths for the client becouse every file which will be received by client should be stored with one path from the received list). I still can't get a rid of this way of thinking about the problem, which was presented in the first post. I wrote it and understand it perfectlly. I still see it like this:

    -server sends size of "thing" that will be sended in a second
    -client receives size of "thing"(client know that firstly it will get the size)
    -server sends the "thing"
    -client knows that the "thing" will be now received and thx to the size(that it has just received), client knows how big the "thing" will be.

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QSslSocket vs QTcpSocket problem

    Maybe you see it like this but you didn't implement it like this.
    -server sends size of "thing" that will be sended in a second
    -server sends the "thing"
    Qt Code:
    1. QDataStream out(&block, QIODevice::WriteOnly);
    2. //serverfiles is a QStringList
    3. out << (out,serverfiles);
    4. serverSocket->write(block);
    To copy to clipboard, switch view to plain text mode 
    Doesn't seem equivalent to me.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. #12
    Join Date
    Mar 2011
    Posts
    53
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSslSocket vs QTcpSocket problem

    ups it should look like this
    Qt Code:
    1. out << (out, serverfiles.size());
    2. serverSocket->write(block);
    3. block.clear();
    4. out << (out, serverfiles);
    5. serverSocket->write(block);
    6. block.clear();
    To copy to clipboard, switch view to plain text mode 

    This:
    Qt Code:
    1. out << (out, serverfiles);
    To copy to clipboard, switch view to plain text mode 
    I've also found it in Qt Assistant-as a way of sending QtStringList in right way.

    Generally as you can see when client connects to the server it always looks like this;
    server sends QStringList
    client sends his QStringList
    server sends files

    That is way my first code wasn't random in its simple construction.

Similar Threads

  1. problem with QTcpSocket
    By Fallen_ in forum Qt Programming
    Replies: 10
    Last Post: 28th November 2010, 11:03
  2. QSslSocket - problem with connecting to the server
    By kremuwa in forum Qt Programming
    Replies: 9
    Last Post: 26th August 2010, 14:40
  3. Problem in QTcpSocket
    By navi1084 in forum Qt Programming
    Replies: 2
    Last Post: 16th October 2008, 12:12
  4. QSslSocket problem
    By The Storm in forum Qt Programming
    Replies: 5
    Last Post: 23rd March 2008, 12:58
  5. problem with QTcpSocket
    By SuperSonik in forum Qt Programming
    Replies: 8
    Last Post: 31st January 2007, 16:00

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.