Results 1 to 3 of 3

Thread: QTCPSocket data tranfser

  1. #1
    Join Date
    Oct 2011
    Posts
    48
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    6

    Default QTCPSocket data tranfser

    Hi,

    I have two applications , a server and a client. My requirement is to send 20 bytes packets continuously to the server for which the server should acknowledge the client with another 20 bytes packet.

    I am sending each 20 bytes packet to server. Server is using the readyRead signal to receive data. But the signal is emitted only after transferring the last 20 bytes packet and data received is a large packet(Combining all the packets).

    I want the readyRead signal to be emitted for each 20 bytes packet.So that I can send back the acknowledgment from the server.

    Please advice any method.

    Thanks In Advance

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QTCPSocket data tranfser

    You need to force flusing the socket on the sending side. However this won't guarantee you'll get a separate readyRead() signal for each packet on the receiving side. Nothing will guarantee that except changing the protocol as this is how TCP works -- it has no notion of "records" or "messages", just a contignous flow of bytes.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    A9am (10th October 2013)

  4. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: QTCPSocket data tranfser

    If you want to deal with individual packets then you need a packet oriented protocol, rather than a stream oriented on, as wysota has pointed out.
    E.g. UDP instead of TCP

    Cheers,
    _

  5. The following user says thank you to anda_skoa for this useful post:

    A9am (16th October 2013)

Similar Threads

  1. Cannot send data with QTcpSocket
    By stef13013 in forum Qt Programming
    Replies: 6
    Last Post: 1st September 2012, 12:00
  2. QTcpSocket no more data only for some sites
    By giusepped in forum Qt Programming
    Replies: 3
    Last Post: 10th August 2011, 11:10
  3. QTcpSocket - making sure all data was sent
    By eliben in forum Qt Programming
    Replies: 4
    Last Post: 10th July 2011, 12:33
  4. QTCPSocket not getting all data
    By jhowland in forum Qt Programming
    Replies: 4
    Last Post: 29th January 2010, 15:20
  5. QTcpSocket + receiving data
    By navi1084 in forum Qt Programming
    Replies: 1
    Last Post: 2nd June 2009, 08:10

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.