Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Why doesn cURL return an error when the network cable is unplugged?

0
Posted

Why doesn cURL return an error when the network cable is unplugged?

0

Unplugging the cable is not an error situation. The TCP/IP protocol stack was designed to be fault tolerant, so even though there may be a physical break somewhere the connection shouldn’t be affected, just possibly delayed. Eventually, the physical break will be fixed or the data will be re-routed around the physical problem. In such cases, the TCP/IP stack is responsible for detecting when the network connection is irrevocably lost. Since with some protocols it is perfectly legal for the client wait indefinitely for data, the stack may never report a problem, and even when it does, it can take up to 20 minutes for it to detect an issue. The curl option –keepalive-time enables keep-alive support in the TCP/IP stack which makes it periodically probe the connection to make sure it is still available to send data. That should reliably detect any TCP/IP network failure. But even that won’t detect the network going down before the TCP/IP connection is established (e.g. during a DNS lookup

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123