Results 1 to 19 of 19

Thread: QTcpSocket problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2012
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QTcpSocket problem

    Hi,

    When I use a QTcpSocket in a desktop Qt 5 app built and run on osx I seem to have a problem which makes my new app unusable if I can't fix it.

    My Qt app creates a socket connection to my server app on an Android device and this all works as it should but then when I want to write data to the socket sometimes (mostly sends instantly) Qt won't send it straight away but the delay is sometimes minutes, sometimes it's been nearly 5 minutes before the server receives the data on the already opened socket.

    I have spent a couple of days researching and nowhere do I find this kind of delay to be something we have to put up with if using TCP (I have read about and disabled Nagle algorithm).

    When the problem occurs I don't see the data in Wireshark when I send it (triggered from a button press on my Qt app) for the minutes until it arrives on my android device so that's make me sure it's related to my Qt side.

    I am sending very small strings when I write to the socket which are less than 20 characters long are always terminated with "\n".

    I have tried using waitForBytesWritten() and various socket options such as the ones below with no success in making my QTcpSocket send the data I write to it within a few seconds, can anyone explain why the data would just be sat somewhere for minutes before being sent sometimes?

    socket->setSocketOption(QAbstractSocket::SendBufferSizeSo cketOption,5);
    socket->setSocketOption(QAbstractSocket::LowDelayOption,1 );
    socket->setSocketOption(QAbstractSocket::KeepAliveOption, 1);

    Thank you.

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

    Default Re: QTcpSocket problem

    This is very uncommon, even a plain TCP socket (without any specially set options) should not do that.

    I assume you are not blocking the thread that runs the event loop used by the QTcpSocket?

    Does it work if you run the server on the same machine?

    Cheers,
    _

Similar Threads

  1. problem with QTcpSocket
    By Fallen_ in forum Qt Programming
    Replies: 10
    Last Post: 28th November 2010, 11:03
  2. QTcpSocket problem
    By MSUdom5 in forum Qt Programming
    Replies: 3
    Last Post: 23rd February 2010, 15:23
  3. Problem in QTcpSocket
    By navi1084 in forum Qt Programming
    Replies: 2
    Last Post: 16th October 2008, 12:12
  4. problem with QTcpSocket
    By SuperSonik in forum Qt Programming
    Replies: 8
    Last Post: 31st January 2007, 16:00
  5. QTcpSocket disconnection problem
    By erdi in forum Qt Programming
    Replies: 4
    Last Post: 19th February 2006, 21:50

Tags for this Thread

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.