understand KeepAlive issues on Socket programing in C#

  • Thread starter Thread starter Ignacio Machin \( .NET/ C# MVP \)
  • Start date Start date
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

semedao said:
Hi,
I want to implement keepalive on connected socket between 2 machines ,
that can be behind NAT.

Why you want this?
I dont remember the last time I had to go so especific to establish a TCP
connection, 99.999% of the time you have enough by using TCPClient
I saw the
SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, 1)

and the IOControlCode.KeepAliveValues options.

But I didn't found article that explain how to use it.

My suggestion is to look into the unmanaged world. These options are not
used that often and you will find more info about it from Unix programming
(I think)
 
Hi,
I want to implement keepalive on connected socket between 2 machines , that
can be behind NAT.

I saw the
SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, 1)

and the IOControlCode.KeepAliveValues options.

But I didn't found article that explain how to use it.

1. both machines need to call those methods?

2. what the difference between the setsocketoption and the IOControl option
, and I need to use both , or only one of them ?

3. There is difference if I call those method before I connect the sockets
or after ?

4. there is difference if I am behind NAT ?

5. how to use the IOControl ? (syntak , values)

In general , there is good article about those issues ?

thanks a lot
 
Back
Top