Results 1 to 5 of 5

Thread: QTcpSocket stays in ConnectingState after reconnection

  1. #1

    Default QTcpSocket stays in ConnectingState after reconnection

    I have a problem with QTcpSocket. I use it to connect with hardware through ethernet port. Everything works ok, I even created a timer, which fires every 2s to check, whether connection is still alive. When i plug out the Ethernet cable, my program shows information about lost connection. Then when I plug cable again, Qt won't allow me to connect again for some time (5-10 minutes). It finds hosts and stays in connecting state. This happend even when I restart the application - it does not help. The same problem does not exist i software provided by hardware manufacturer. Could you tell mi what is wrong?

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

    Default Re: QTcpSocket stays in ConnectingState after reconnection

    You're not setting a SO_REUSEADDR flag on the socket and the hardware manufacturer probably does. Qt has nothing to do with this, it is your operating system that prevents a quick connection on a port that recently has not been closed gracefully.
    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. #3

    Default Re: QTcpSocket stays in ConnectingState after reconnection

    Ok, where can I do this? I've compiled the program both on Ubuntu and Windows, the result is the same. But the manufacturer's software manages to reconnect succefully, even though I am blocked.

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

    Default Re: QTcpSocket stays in ConnectingState after reconnection

    man setsockopt
    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.


  5. #5
    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 stays in ConnectingState after reconnection

    Hmm, I have to say I am also quite puzzled by this.
    I have done tons of network programming with Qt and I've never seen this happen.

    Especially not on unrelated sockets. And restarting the application is as unrelated as it gets

    What happens if you try to connect with telnet after the connection has been lost and cable has been reconnected?
    Can it connect successfully?

    Cheers,
    _

Similar Threads

  1. QMdiSubWindow stays always on top
    By SiS-Shadowman in forum Qt Programming
    Replies: 0
    Last Post: 20th July 2010, 17:55
  2. QTemporaryFile stays locked even after calling close()
    By Tiansen in forum Qt Programming
    Replies: 1
    Last Post: 20th May 2010, 13:35
  3. QTcpSocket: ConnectingState
    By fruzzo in forum Qt Programming
    Replies: 7
    Last Post: 11th August 2009, 13:25
  4. QComboBox that stays expanded
    By jma in forum Qt Programming
    Replies: 2
    Last Post: 21st January 2009, 07:50
  5. QSystemTray stays longer than it should !
    By probine in forum Qt Programming
    Replies: 2
    Last Post: 21st December 2006, 11:37

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.