QTcpSocket SO_KEEPALIVE, Qt4 vs Qt5
-
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?
-
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?