Results 1 to 9 of 9

Thread: QTcpSocket::readyRead() lost messages, performance issue?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2009
    Location
    Italy
    Posts
    70
    Thanks
    23
    Thanked 15 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTcpSocket::readyRead() lost messages, performance issue?

    Here are two major problems I can see with the code you posted:

    1) if readyRead() is called and there are less than 100 bytes in the socket, you
    emit an incomplete message. The Fortune Client calls bytesAvailable()
    to prevent this.

    2) if readyRead() is called with more than 100 bytes, you are "packing" them
    together in a single message (and, as above, the last part of the message might be incomplete).
    This is weird because you say you are working with messages of 100 bytes each.

    Also, when you call QString(buf) you are making two assumption that
    I cannot verify:

    1) the received data has no embedded zeroes
    2) the received data is text encoded with the default encoding (QTextCodec::codecForCStrings())

  2. The following user says thank you to mattc for this useful post:

    Juba (7th June 2011)

  3. #2
    Join Date
    May 2010
    Posts
    11
    Thanks
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QTcpSocket::readyRead() lost messages, performance issue?

    Ok mattc, thank you for reviewing my code, but your post don't focus the problem...

    When readyRead() is emitted I always read the correct messages, the problem is that readRead() seems to be not emitted in certain conditions.
    The condition isn't easily reproducible, sometime a the burst of 4 messages is received, sometime the client lose the third message...

  4. #3
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTcpSocket::readyRead() lost messages, performance issue?

    Have you tried the different connection options, such as DirectConnection (assuming slot is in same thread as signal), QueuedConnection, etc?

Similar Threads

  1. QtcpSocket readyRead Problem with Java Client
    By Bernie in forum Qt Programming
    Replies: 6
    Last Post: 12th February 2011, 11:59
  2. QTcpSocket readyRead strange behavior
    By naroin in forum Qt Programming
    Replies: 46
    Last Post: 21st January 2011, 22:28
  3. QTcpSocket and readyRead and QTimer
    By cafu in forum Qt Programming
    Replies: 2
    Last Post: 18th December 2009, 13:36
  4. Question in readyRead(QTCPSOCKET)
    By morgana in forum Qt Programming
    Replies: 2
    Last Post: 24th July 2008, 18:11
  5. QTcpSocket readyRead and buffer size
    By pdoria in forum Qt Programming
    Replies: 4
    Last Post: 2nd February 2008, 10:11

Tags for this Thread

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.