[Qt-interest] QTcpServer timeout ?
BRM
bm_witness at yahoo.com
Tue Jul 20 23:23:19 CEST 2010
There is also another solution, though you may have to fall-back to some
platform specific code to enable it.
Both Windows and Linux do have system level timers on the sockets. However, you
can set a KEEP_ALIVE socket option.
While this can be specified on the socket creation (e.g. open()), it can also be
set via the socket options (setsockopt() for Linux).
The KEEP_ALIVE option basically makes the operating system send the messages at
the TCP protocol layer (per RFC 1122);
thus you don't have to generate or parse more messages or have to maintain a
timer yourself to send them.
http://en.wikipedia.org/wiki/Keepalive#TCP_Keepalive
http://tldp.org/HOWTO/TCP-Keepalive-HOWTO/usingkeepalive.html
http://msdn.microsoft.com/en-us/library/ms819735.aspx
I could not quickly spot a way to get Qt to do this for you.
HTH,
Ben
>
>From: Atlant Schmidt <aschmidt at dekaresearch.com>
>To: David Boosalis <david.boosalis at gmail.com>; QtInterest
><qt-interest at trolltech.com>
>Sent: Tue, July 20, 2010 4:01:13 PM
>Subject: Re: [Qt-interest] QTcpServer timeout ?
>
>
>David:
>
> It’s quite common for TCP connections of all sorts to have an inactivity
>timer.
> This is especially true if your session connects through a firewall or a
>“public”
> medium.
>
> Because you often can’t affect the settings of the various inactivity timers
> you may encounter along the way, the usual solution is, as you surmised,
> the use of keep-alive messages. I’m thinking that every five minutes is
> too long, but that will depend on your particular circumstances.
>
> Atlant
>
>
________________________________
>From:qt-interest -bounces at trolltech.com [mailto: qt-interest
>-bounces at trolltech.com] On Behalf Of David Boosalis
>Sent: Tuesday, July 20, 2010 3:51 PM
>To: QtInterest
>Subject: [Qt-interest] QTcpServer timeout ?
>
>I have Qt Client applications establishing connections to server apps based
>using QtTcpServer(s). The sockets that send data quite often have no problem
>staying connected all day. However the sockets that send notices maybe one
>every two hours or perhaps just once a day tend to die. I never see a
>disconnect, but the socket just seems to go to sleep as data fails to arrive to
>the server. I was wondering if a time out occurring due to the lack of
>activity going across the socket. I looked at the QTcpServer class for a method
>that might turn off such a timer but did not see any. Perhaps this behaviour
>goes beneath QT and into the Linux Tcp Server design. If so is there a low
>level call I can make on the socket ID to keep the connection always alive. I
>am thinking about sending a ping every 5 minutes on these sockets.
>
>
>Any advise on how best to fix this time out is very much appreciated.
>
>-David
>
>
>
>Click here to report this email as spam.
>________________________________
This e-mail and the information, including any attachments, it contains are
intended to be a confidential communication only to the person or entity to whom
it is addressed and may contain information that is privileged. If the reader
of this message is not the intended recipient, you are hereby notified that any
dissemination, distribution or copying of this communication is strictly
prohibited. If you have received this communication in error, please immediately
notify the sender and destroy the original message.
>
>Thank you.
>
>Please consider the environment before printing this email.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100720/74547f11/attachment.html
More information about the Qt-interest-old
mailing list