0

I have a non-blocking IPv4 TCP socket, when I try to connect(), I get the errno ETIMEDOUT. It confused me a lot, since I have not set timeout on socket. What is some possible reasons of this case?

Dawn16
  • 140
  • 8
  • Are you sure the socket is non-blocking? I would not expect this error when doing a `connect` on a non-blocking socket but instead `EINPROGRESS`. – Steffen Ullrich Apr 04 '20 at 16:01
  • @SteffenUllrich it is possible to fail the fnctl() since I have not done error check at fnctl() return value, however, if it is failed, then it should be blocking forever, since I have not set the timeout value. – Dawn16 Apr 04 '20 at 18:17
  • @SteffenUllrich Also, suppose fnctl() failed, it fails always. Since my system has retry mechanism. If fails, socket will be closed and then create a new, set non blocking again. How it is possible that other options set correctly except fnctl(). It is a rare case that fnctl() failed in my opinion. – Dawn16 Apr 04 '20 at 18:25
  • Based on what you write it seems to be that your code is missing error checks and you don't really know exactly where this problem comes from. I think you need to provide a [Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) so that one can look at what really causes the problem instead of just making (maybe unfounded) assumptions. – Steffen Ullrich Apr 04 '20 at 18:36
  • @SteffenUllrich From logic reasoning, I am sure it is non blocking. I will check the Linux kernel. My kernel is not a standard Linux kernel, probably it has some strange thing maybe. So thank you for your help anyway. – Dawn16 Apr 04 '20 at 19:38

1 Answers1

0

From man page:

ETIMEDOUT:

Timeout while attempting connection. The server may be too busy to accept new connections. Note that for IP sockets the timeout may be very long when syncookies are enabled on the server.

You can also see ETIMEDOUT in this quesiton How to handle ETIMEDOUT error

Community
  • 1
  • 1
Hitokiri
  • 3,607
  • 1
  • 9
  • 29