Results 1 to 2 of 2

Thread: Packet handling advice with QTcpSocket?

  1. #1
    Join Date
    Apr 2010
    Posts
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Packet handling advice with QTcpSocket?

    Hi

    I'm currently developing a network application, and I've run into a few problems with my readyRead() handler. It works fine at low speeds, but it seems that once it receives a couple of packets at once it can start to corrupt the packet data?

    I prepend a header portion (3 bytes) to each packet that includes a char at the front to identify the packet type and two bytes reserved for its size (quint16).

    How can I optimize the code to work with large amounts of packets (and incomplete packets) per read?
    Here's my readyRead() handler code: (It reads the packet and sends it to a specific UDP port on the localhost)

    Thanks!

    EDIT: It seems this isn't the problem as I compared precalculated checksums with checksum calculated after the block is received and they are identical. So if anything it might be the speed/order in which they are received/sent.
    Last edited by zAAm; 24th April 2010 at 15:22.

  2. #2
    Join Date
    Aug 2006
    Posts
    221
    Thanks
    3
    Thanked 29 Times in 19 Posts

    Default Re: Packet handling advice with QTcpSocket?

    You are using UDP? Then the behaviour is totally correct. In UDP you have no guarantee in what order you receive sent packages.
    http://www.cafeaulait.org/course/week12/35.html
    You have to add something like a sequence number.

Similar Threads

  1. Packet getting fragmented when sending over QTcpSocket
    By arturo182 in forum Qt Programming
    Replies: 14
    Last Post: 5th August 2009, 23:11
  2. Need Advice: Best IDE for Mac OSX
    By JimDaniel in forum Qt Programming
    Replies: 6
    Last Post: 18th October 2008, 23:14
  3. Advice for a new Project
    By hardgeus in forum Qt Programming
    Replies: 3
    Last Post: 18th April 2008, 08:01
  4. how to send ICMP packet
    By eleanor in forum Qt Programming
    Replies: 2
    Last Post: 30th October 2007, 14:23
  5. QtNetwork send ICMP Packet
    By SlowTree in forum Qt Programming
    Replies: 3
    Last Post: 29th October 2007, 20:13

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.