Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTcpSocket SO_KEEPALIVE, Qt4 vs Qt5

QTcpSocket SO_KEEPALIVE, Qt4 vs Qt5

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 2.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    luca
    wrote on last edited by
    #1

    Hi all,
    I got a strange problem in porting my Qt4 app to Qt5.

    In my app I have this part of code:
    @
    int fd = m_starSocket->socketDescriptor();
    int enableKeepAlive = 1;
    setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &enableKeepAlive, sizeof(enableKeepAlive));
    int max_idle = 120;
    setsockopt(fd, SOL_TCP, TCP_KEEPIDLE, &max_idle, sizeof(max_idle));
    int keep_count = 5;
    setsockopt(fd, SOL_TCP, TCP_KEEPCNT, &keep_count, sizeof(keep_count));
    int keep_interval = 10;
    setsockopt(fd, SOL_TCP, TCP_KEEPINTVL, &keep_interval, sizeof(keep_interval));
    @

    This way my app, if I unplug ethernet cable, closes tcp socket connection after some minutes.
    The problem is that Qt5 version of my app (with the same source code) seems to ignore my keepalive parameters and never close tcp socket connection.

    What does it should be the problem?

    1 Reply Last reply
    0
    • L Offline
      L Offline
      luca
      wrote on last edited by
      #2

      In QTcpSocket documentation I found this:
      @
      If the socket is using QNetworkProxy, the returned descriptor may not be usable with native socket functions.
      @

      Should it be that the problem?
      Is there a difference between Qt4 and Qt5 in QTcpSocket about QNetworkProxy?

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved