Hi,
I have a C# TCP client program. I want to make use of the KeepAlive
functionality to check that the connection is still alive after some time
interval. I try to use the SetSocketOption method to change the KeepAlive
interval (default is 2 hours) to be shorter, but it doesn't work. The
KeepAlive founction is activated by the SetSocketOption method, but the time
interval is still 2 hours.
This is my code:
client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive,
5000);
"client" is the socket in the client side.
I would like to ask two questions:
1. How can I change the KeepAlive time interval?
2. Can I activate the KeepAlive functionality for only one socket and other
TCP progams in the system won't be affected?
Thank you,
Ken
Chris - 29 Oct 2004 18:35 GMT
> Hi,
> I have a C# TCP client program. I want to make use of the KeepAlive
[quoted text clipped - 17 lines]
> Thank you,
> Ken
Hi Ken,
I believe that the SetSocketOption for KeepAlive just enables/disables
KeepAlive. It doesn't set the KeepAlive time interval. This interval should
be configurable (see section 4.2.3.6 of RFC 1122). This change however would
affect the time interval of all applications with KeepAlive enabled.
Also note that RFC 1122 says that KeepAlive should only be invoked in server
applications. See the above mentioned section for more details.
As for setting the KeepAliveTime interval, it will be platform specific.
For example, in Windows 2003 you would want to see
http://www.microsoft.com/resources/documentation/WindowsServ/2003/all/deployguid
e/en-us/Default.asp?url=/resources/documentation/windowsserv/2003/all/deployguid
e/en-us/58767.asp
-Chris