What does QAbstractSocket::KeepAliveOption actually do?
-
The documentation is a bit unclear, but if I enable
QAbstractSocket::KeepAliveOption
on a TCP socket, will it automatically send the keepalive packets for me? -
@Vadi2
as the docs also state it sets theSO_KEEPALIVE
option on the underlying platform socket.
So you should look up this option for your target platform. -
-
@Vadi2
Behaviour ofSO_KEEPALIVE
varies enormously between various OSes, different TCP stacks, etc. You really do have to do a lot of reading (e.g. @raven-worx's link, stackoverflow etc.) if you really know what it might or might not do.My experience (maybe a bit old now)? Don't rely on it to do anything.
Or, in particular: I used to use to (try to) keep a connection from timing out. In practice, far from that, what it actually did was: caused my app to notice that a connection had become lost, and so complain, when had I not used it then the app wouldn't have noticed a lost connection till I sent/received, and by then might have silently re-established the connection without complaint. So I gave up on it!