Search code examples
.netsocketskeep-alive

Where to get specification for keep-alive in sockets in .NET?


I'm trying to find out how exactly keep-alive works in .NET but link from here doesn't work. Could anybody post a link with specification?

What I'm looking for:

  • I would like to know how often are the keep-alive packets sent.

  • Do I have to set KeepAlive via command:

    s.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);

    only at the server side or even the client has to set this flag?


Solution

  • Not sure this is what you are looking for, but the SocketOptionName enum has a KeepAlive member, as can be seen here.

    From the documentation, you would use it this way:

    s.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);