Re: Should a socket client detect loss of network connection
- From: "Alexander Nickolov" <agnickolov@xxxxxxxx>
- Date: Tue, 10 Apr 2007 11:31:37 -0700
The following is what RFC 1122 has to say on the subject:
4.2.3.6 TCP Keep-Alives
Implementors MAY include "keep-alives" in their TCP
implementations, although this practice is not universally
accepted. If keep-alives are included, the application MUST
be able to turn them on or off for each TCP connection, and
they MUST default to off.
Keep-alive packets MUST only be sent when no data or
acknowledgement packets have been received for the
connection within an interval. This interval MUST be
configurable and MUST default to no less than two hours.
It is extremely important to remember that ACK segments that
contain no data are not reliably transmitted by TCP.
Consequently, if a keep-alive mechanism is implemented it
MUST NOT interpret failure to respond to any specific probe
as a dead connection.
An implementation SHOULD send a keep-alive segment with no
data; however, it MAY be configurable to send a keep-alive
segment containing one garbage octet, for compatibility with
erroneous TCP implementations.
Microsoft's implementation certainly conforms.
TCP keep-alives are certainly not good enough for maintaining
bindings at NAT routers.
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@xxxxxxxx
MVP VC FAQ: http://vcfaq.mvps.org
=====================================
"Roger Hunen" <rhunen@xxxxxxxxx> wrote in message
news:461bd016$0$323$e4fe514c@xxxxxxxxxxxxxxxxx
"Alexander Nickolov" <agnickolov@xxxxxxxx> wrotel...
That "apart from" statement answers your question. It's the only
way.
setsockopt (...., SO_KEEPALIVE, ....) looks like that other way to me.
The only problem with SO_KEEPALIVE is that the Windows default
keepalive timeout is very long (2 hours) and that you cannot set this
timeout at the socket level (it is a system wide registry setting).
Regards,
-Roger
--
E-mail: rhunen@xxxxxxxxx
Home: http://www.xs4all.nl/~rhunen
ADSL: http://adsl.hunen.net
"Angus" <nospam@xxxxxxxxx> wrote in message
news:ewX3O44eHHA.4136@xxxxxxxxxxxxxxxxxxxxxxx
Thank you, I have checked with the client and it is a router causing
this
problem. So what you suggest sounds like the easiest solution.
It would be most convenient if the client could 'detect' that the
connection
'session' was no longer valid. Is there any way of checking this apart
from
sending data to the server? I assume not.
Angus
"Alexander Nickolov" <agnickolov@xxxxxxxx> wrote in message
news:uXVPrbseHHA.5052@xxxxxxxxxxxxxxxxxxxxxxx
Sounds like a NAT router in between dropping its TCP binidingsthis
for your connection due to inactivity. You must include some sort
of keep-alive mechanism in your protocol in case of regular data
inactivity, otherwise you are subject to the NAT router issue.
BTW, before you ask there's no standard threshold when a NAT
router considers a TCP connection inactive. Personally I wouldn't
trust a conection with 5 minutes inactivity alive through a NAT router.
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@xxxxxxxx
MVP VC FAQ: http://vcfaq.mvps.org
=====================================
"Angus" <nospam@xxxxxxxxx> wrote in message
news:uicy3KseHHA.5056@xxxxxxxxxxxxxxxxxxxxxxx
Hello
I have written a socket client and a server. When I test on my test
system
it seems to work fine. But a user has reported that if they leave
the
system running with no activity for over an hour then the server
stops
sending data to the client.
I have setup on a test system on different computers and I don't see
itproblem after one hour. Most of the activity is server to client.
So in my testing I tried taking the ethernet cable out of the server
PC.
Neither my server or client seemed to detect this. Should they be
able
to?
If so how?
Has anyone seen this type of problem? Any ideas on how to
troubleshoot
re-connectand resolve? It is only a problem apparently after a long period of
inactivity. If there is data sent from server to client within a
reasonable
period there is no problem. I think if the user goes to lunch (or
away
for
a period) then the way the system works there would be no data from
the
server. If they get back after an hour or so then they need to
from client to see any further data communication.
Angus
.
- Follow-Ups:
- Re: Should a socket client detect loss of network connection
- From: Roger Hunen
- Re: Should a socket client detect loss of network connection
- References:
- Should a socket client detect loss of network connection
- From: Angus
- Re: Should a socket client detect loss of network connection
- From: Alexander Nickolov
- Re: Should a socket client detect loss of network connection
- From: Angus
- Re: Should a socket client detect loss of network connection
- From: Alexander Nickolov
- Re: Should a socket client detect loss of network connection
- From: Roger Hunen
- Should a socket client detect loss of network connection
- Prev by Date: Re: Native WiFi API with 802.1x on Windows XP SP2.
- Next by Date: ConnectEx and SO_UPDATE_CONNECT_CONTEXT
- Previous by thread: Re: Should a socket client detect loss of network connection
- Next by thread: Re: Should a socket client detect loss of network connection
- Index(es):
Relevant Pages
|