2

Can any one tell me the difference between TTL and Keep alive in sockets (C# Networking) and also Linger.. Thanks in advance.

C-va
  • 2,910
  • 4
  • 27
  • 42

2 Answers2

3

TTL tells the packet how many routers he can go through before giving up, while Keep Alive tells the connexion how long it must be kept open without activity.

From what i read about Linger, i don't see the difference with keep-alive, i may be missing something here.

EDIT: The linger option allows you to close the socket while telling it to wait some time to see if data is still on the wire; from this page, we read that

There may still be data available in the outgoing network buffer after you close the Socket. If you want to specify the amount of time that the Socket will attempt to transmit unsent data after closing, create a LingerOption with the enabled parameter set to true, and the seconds parameter set to the desired amount of time. The seconds parameter is used to indicate how long you would like the Socket to remain connected before timing out. If you do not want the Socket to stay connected for any length of time after closing, create a LingerOption with the enabled parameter set to false. In this case, the Socket will close immediately and any unsent data will be lost. Once created, pass the LingerOption to the Socket.SetSocketOption method. If you are sending and receiving data with a TcpClient, then pass the LingerOption to the TcpClient.LingerState method.

samy
  • 14,832
  • 2
  • 54
  • 82
  • Thank u. What is the use of setting Linger ? – C-va Jul 27 '11 at 09:45
  • the linger option can be used to "skip" the TIME-WAIT status on a TCP-Connection. Although it's possible to skip this state, be aware of the consequences of skipping!! We found the linger option quite useful while communication with HTTP/1.0 servers (a lot). – Chris Jul 27 '11 at 10:00
1

Time to live is the number of devices (hops) a network packet may cross (like routers, switches etc) Keep alive time is the time the socket stays open when no data is being send or received

Thomas
  • 595
  • 1
  • 5
  • 20