Results 1 to 2 of 2

Thread: QTcpSocket + receiving data

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

    Default QTcpSocket + receiving data

    Hi all,
    My Pc is connected to a host using TCP connection. My pc acts as client and host acts as server.
    In a perticular case server should send two types of results/response. first result should contains large chunks of data and second is below 100 bytes. The problem occures when this data arrives at my pc. The problem is:
    It can be seen that (using wireshark) all the datas sent by the server is reaching my pc( Both responses at once) whenever i request. But the first response will be received and triggers signal readyread() and i can extract the data. But 2nd response will trigger the signal readyread(), only when i request next time.

    Steps:
    1:Client: Request for the Data
    2:Server: Sends two separate responses. Client will recieve successfully all the data(Checked using wireshark).
    3: Client: Socket class triggers readReady() signal for first response. and extract the data.
    4: Client: Socket class should trigger readReady() signal for second response. but it wont.
    5: Client: Request for the Data:
    6: Client: Socket class trigger readReady() signal for second response of previous request.
    7: Client: Socket class triggers readReady() signal for first response of current request. and extract the data.
    .
    .
    .

    Can anyone tell me how can i resolve this problem such away that both responses evaluated in the same request.

  2. #2
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTcpSocket + receiving data

    Hi Naveen,
    I think, I know whats wrong here.

    You checked with wireshark that data is coming to your PC at once not in two packets (big+small).
    So this is the answer of your problem. That ReadyRead signal will emit only once, because data is coming only once.

    You can read all data using socket->readAll().
    You can check is there any data by socket->bytesAvailable().

Similar Threads

  1. Problem with reading in data from a QTCPSocket
    By Denarius in forum Qt Programming
    Replies: 4
    Last Post: 24th April 2009, 08:54
  2. Problem in printing the data return /read from QTcpsocket
    By skumar434 in forum Qt Programming
    Replies: 3
    Last Post: 20th February 2009, 19:36
  3. Best way to display lots of data fast
    By New2QT in forum Newbie
    Replies: 4
    Last Post: 16th October 2008, 22:46
  4. Replies: 7
    Last Post: 29th August 2008, 10:24
  5. data at fifo's receiving end has arrived?
    By quickNitin in forum General Programming
    Replies: 4
    Last Post: 5th November 2006, 10: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.