Results 1 to 4 of 4

Thread: QTcpSocket no more receives data after some time

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QTcpSocket no more receives data after some time

    Hi guys !
    I'm programming a little application which is used to communicate with an electronic cards trough Ethernet by using tcp/ip ! my application send commands and the card respond by "OK" or some data measured !

    For each data send I wait then for the answer with waitForReadyRead(), but after some commands no more data are received and the timeout of waitForReadyRead() appears but when I analyse the Ethernet traffic, I view that the packet are send to my computer...

    I use some threads which allow me to communicate with many cards, so I create my socket my qmainwindows class that then I transmit to my QThread subclass and connectTohost before call start method !

    I hope you arrive to see what I mean !

    Thanks
    Last edited by ben_m; 22nd June 2011 at 09:31.

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTcpSocket no more receives data after some time

    How do you read data sent from device?

    Remember that TCP has not the concept of "single packet" as UDP; so you need to read the correct amount of data.

    Can you post the code??
    A camel can go 14 days without drink,
    I can't!!!

  3. #3
    Join Date
    Jun 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTcpSocket no more receives data after some time

    I simply read with the read method of the tcpSocket after waitforreadyread , but now it seem to work if create the tcpSocket object in the thread itself and not pass it from my windows class ! but it's right that UDP will be more adapted for my application !

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QTcpSocket no more receives data after some time

    The readyRead() signal indicates that some data has been received. It does not indicate that all data has been received and it is not re-emitted if you don't read all the available data unless new data is received. Are you sure you don't have all your data sitting in the buffer and are sitting there waiting for a new readyRead() that will never come?

Similar Threads

  1. QSerial problem:receives random data
    By omegaKnot in forum Qt Programming
    Replies: 5
    Last Post: 27th May 2011, 09:32
  2. Replies: 5
    Last Post: 19th November 2010, 02:25
  3. QTCPSocket not getting all data
    By jhowland in forum Qt Programming
    Replies: 4
    Last Post: 29th January 2010, 15:20
  4. QTcpSocket - speed, latency, time
    By FatScouser in forum Qt Programming
    Replies: 2
    Last Post: 19th January 2010, 12:25
  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.