Home > Back-end >  libcurl - CURLOPT_TCP_KEEPIDLE and CURLOPT_TCP_KEEPINTVL
libcurl - CURLOPT_TCP_KEEPIDLE and CURLOPT_TCP_KEEPINTVL

Time:12-04

Please tell me what is the difference between the parameters: CURLOPT_TCP_KEEPIDLE and CURLOPT_TCP_KEEPINTVL ?

CURLOPT_TCP_KEEPIDLE: Sets the delay, in seconds, that the operating system will wait while the connection is idle before sending keepalive probes. Not all operating systems support this option.

CURLOPT_TCP_KEEPINTVL: Sets the interval, in seconds, that the operating system will wait between sending keepalive probes. Not all operating systems support this option.

-I understand it like this: CURLOPT_TCP_KEEPIDLE - this means that how long will the OS wait for some "keepalive probes" from the server side before the OS thinks that the connection has drop ?

-But I can't understand this: CURLOPT_TCP_KEEPINTVL - set interval...in which OS will wait between .... Between what? Interval between what and what ?

CodePudding user response:

TCP keep alive sends "keep alive" probes (small IP packages) between both endpoints.

If no data has been transferred over the TCP connection for a certain period, the TCP endpoint will send a keep alive probe. This period is CURLOPT_TCP_KEEPIDLE.

If the other endpoint is still connected, the other endpoint will reply to the keep alive probe.

If the other endpoint does not reply to the keep alive probe, the TCP endpoint will send another keep alive probe after a certain period. This period is CURLOPT_TCP_KEEPINTVL.

The TCP endpoint will keep sending keep alive probes until the other endpoint sends a reply OR a maximum number of keep alive probes has been sent. If the maximum number of keep alive probes has been sent without a reply form the other endpoint, the TCP connection is no longer connected.

  • Related