Results 1 to 2 of 2

Thread: QTcpSocket read duplicate data, but only on "bad channel"

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2008
    Posts
    15
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTcpSocket read duplicate data, but only on "bad channel"

    I have a client socket class defined as

    class ClientSocket : public QTcpSocket
    {
    ...
    I write socket data as follows
    code
    write ((const char *) &buffer, data_packet.size + HEADER_SIZE);
    while (waitForBytesWritten (100) == -1);
    /code
    (Note data_packet.size + HEADER_SIZE == 1024)

    The same class is used in the client, receiving data connecting the readyRead signal to a slot

    slot ..
    code
    index = 0;
    forever {
    amount = bytes_available();
    if (amount > 0)
    index + = read ((const char *)&buffer[0] + index, amount);
    etc...
    // until the total amount of bytes is read, Accumulated == 1024, break
    }
    /code

    process the data
    // the data is incorrect at this point

    I only send/receive 1024 bytes at a time, and make up the packets with a packet number and number of packets in the header, the last packet is the one where packet number == number of packets

    My problem is as follows:

    Using a local net work I can send and receive data (files small and big) for days on end without a problem, I could even use my ADSL via a 3G modem without any problem. then I turn to IBurst.

    ( IBurst is a RF network, and is renowned for snail mail, and very slow connections, an ideal test platform to test your software over a bad medium).

    If I write the data using waitForBytesWritten to determine if I can write a new packet, the connections falls over almost immediately. on a bad day. If I wait 300ms between writes, the system perform better, but not alwaysreceive the correct data . The problem is that I get the same data (the packet number is the same) from the read on the receiver side. The wait time is a bad fix, as if the channel get bad, the time needs to be increased more. and one always send /receive file at a snail place.

    I cannot understand the problem as a TCP socket class should sort out the packet buffering. The receiver should get a signal and read the correct data, even if it is less than the packet size, until you have the correct amount.

    Any ideas ?

    Thanks in advance
    Gerrie

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 268 Times in 268 Posts
    Wiki edits
    20

    Default Re: QTcpSocket read duplicate data, but only on "bad channel"

    I must admit that I know absolutely nothing of IBurst, but from reading a little bit on the net I wonder if TCP can be used on top of IBurst.

Similar Threads

  1. Replies: 1
    Last Post: 7th April 2010, 21:46
  2. Replies: 3
    Last Post: 25th August 2009, 13:03
  3. Replies: 2
    Last Post: 11th June 2009, 20:38
  4. Adapting the "Simple DOM Model Example" to be read/write
    By joshuajcarson in forum Qt Programming
    Replies: 7
    Last Post: 8th September 2008, 20:19
  5. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05

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.