Results 1 to 3 of 3

Thread: Problem in QTcpSocket

  1. #1
    Join Date
    Aug 2008
    Posts
    134
    Thanks
    10
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Problem in QTcpSocket

    Hi,
    I am facing a problem in QTcpSocket.
    I need to send consecutive separate packets in network. To send the packets i am using write operation followed by a flush and followed by write once again.
    socket->write(data)
    socket->flush()
    socket->write(data1)
    when i flush the packet and execute write of data1 , then first packet will be lost. If i remove the flush then in same packet data and data1 is passed .
    I need to pass two packets separately without loosing any of them. Please can anyone tell me how can i accomplish it???

    Thank You

  2. #2
    Join Date
    Jan 2007
    Posts
    177
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem in QTcpSocket

    you cant do that this way. you know tcp is a stream, its continous sending data. use udp for data packages or build a package which contains the his own size, so the receiver can read a as many bytes as the packages size is.

  3. #3
    Join Date
    Aug 2006
    Location
    Germany
    Posts
    33
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem in QTcpSocket

    socket->write(data);
    use waitForBytesWritten() in the middle .. wait until ' data' is written
    and then
    socket->write(data1);

    cheers

Similar Threads

  1. Problem with QTcpSocket in QThread
    By Raistlin in forum Qt Programming
    Replies: 8
    Last Post: 6th October 2007, 13:23
  2. QTcpSocket speed problem
    By benelgiac in forum Qt Programming
    Replies: 4
    Last Post: 1st May 2007, 14:50
  3. problem with QTcpSocket
    By SuperSonik in forum Qt Programming
    Replies: 8
    Last Post: 31st January 2007, 17:00
  4. Problem with QTcpSocket and QDataStream
    By Valheru in forum Qt Programming
    Replies: 4
    Last Post: 16th September 2006, 14:08
  5. QTcpSocket disconnection problem
    By erdi in forum Qt Programming
    Replies: 4
    Last Post: 19th February 2006, 22:50

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.