Results 1 to 5 of 5

Thread: (SOLVED) Data loss over tcp connection?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2009
    Posts
    44
    Thanks
    29
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default (SOLVED) Data loss over tcp connection?

    Hi,

    Sometimes the packets i send over the network seems to get lost O.o
    On the local machine all works fine... But not over the internet.

    Client:
    Qt Code:
    1. QByteArray database = inFile.readAll();
    2.  
    3. QByteArray outBlock;
    4. QDataStream out(&outBlock, QIODevice::WriteOnly);
    5. out.setVersion(QDataStream::Qt_4_5);
    6. out << qint64(0) << serverPass << quint16(GET_DB) << database;
    7. out.device()->seek(0);
    8. out << qint64(outBlock.size() - sizeof(qint64));
    9.  
    10. tcpSocket.write(outBlock);
    To copy to clipboard, switch view to plain text mode 

    Now before i send that packet i check the size od database(QByteArray)and it is correct!

    Server code:

    Qt Code:
    1. QDataStream inStream(tcpSocket);
    2. inStream.setVersion(QDataStream::Qt_4_5);
    3.  
    4. /* packet format */
    5. qint64 size2;
    6. QString serverPass2;
    7. quint16 reqType2;
    8. QByteArray data2;
    9.  
    10. inStream >> size2 >> serverPass2 >> reqType2 >> data2;
    To copy to clipboard, switch view to plain text mode 

    now i recive all data correctly except data2 (database) which is a QByteArray with size == 0! But that's not possible, so where is the data? The outgoing array(database) whas not empty...

    Is it possible to loose data over tcp??
    Last edited by giowck; 24th September 2009 at 19:05.

Similar Threads

  1. LocalSocket and Data Loss
    By ManuMies in forum Qt Programming
    Replies: 6
    Last Post: 8th September 2009, 14:32
  2. data rate transfer is decreasing in TCP connection
    By navi1084 in forum Qt Programming
    Replies: 3
    Last Post: 19th June 2009, 16:15
  3. Best way to display lots of data fast
    By New2QT in forum Newbie
    Replies: 4
    Last Post: 16th October 2008, 22:46
  4. loss of data recieved using http->readAll()
    By arunredi in forum Qt Programming
    Replies: 5
    Last Post: 26th June 2008, 17:12
  5. Client/Server Error: BadIDChoice
    By 3nc31 in forum Qt Programming
    Replies: 5
    Last Post: 27th November 2007, 10:22

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.