Results 1 to 2 of 2

Thread: QTcpSocket doesn't recognize network errors! That's bad! Maybe an bug?

  1. #1
    Join Date
    Jun 2010
    Posts
    31
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default QTcpSocket doesn't recognize network errors! That's bad! Maybe an bug?

    Hi there,

    I use the QTcpSocket and QTcpServer classes in my application.
    My application has to make sure that the communication always is ok. If some network error occurs like connection abort the I thougt QTcpSocket recognizes that.

    But NO! You can simple test it with unplugging the network cable on client side. NO stateChange() or error() is called.
    If you unplug the cable on your PC then it's recognized (I think this done by checking hardware directly).

    Also if I set the TCP_KEEPALIVE option there is no diffrent. Default setting of KEEPALIVE is 2 hours!!! on windows. I think only enabling KEEPALIVE is poor. You have additional set the timeouts of that function.

    I wonder me also why the stateChanged() signal is sent if client aborts but if client connects there is no stateChanged() sent.

    A solution is to use a "heartbeat" telegram. But this should done tcp/ip levels and not on users level.

    Any experince?

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTcpSocket doesn't recognize network errors! That's bad! Maybe an bug?

    QTCPSocket recognises some errors, but others can not be detected until you actually try and send data. So in your protocol you should implement heartbeat to test that you can a) send data and b) that the host is still there and replying. It is not upto the network stack to continually test the connection. If you require such functionality you need to implement it.

Similar Threads

  1. QT Creator won't recognize a slot
    By lucasvickers in forum Newbie
    Replies: 4
    Last Post: 1st April 2013, 00:33
  2. Binding QTcpSocket to a specific network interface
    By vkincaid in forum Qt Programming
    Replies: 0
    Last Post: 14th May 2010, 21:28
  3. How do I get Qt to recognize the oci driver.
    By yleesun in forum Qt Programming
    Replies: 11
    Last Post: 19th January 2009, 03:50
  4. QTcpSocket & transfer errors
    By jkam in forum Qt Programming
    Replies: 1
    Last Post: 20th July 2008, 20:42
  5. Getting Qt to recognize plugins...
    By KShots in forum Qt Programming
    Replies: 4
    Last Post: 21st April 2007, 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.