Why SetSocketOption cannot change the KeepAlive time interval

G

Guest

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
 
G

Guest

Ken said:
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

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/...dowsserv/2003/all/deployguide/en-us/58767.asp

-Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top