简体   繁体   中英

Non-blocking connect timeout

I'm perform non blocking connect to server.

What an appropriate timeout value to be used in select to consider the server down/busy?

PS

Connect can fail since server is down or busy.

In case server is down I always will always end with select timeout.

More interesting case is when server is busy. IMHO 1 sec is enough for TCP handshake. If it takes too long time to connect to server, than all communication with the server will be delayed. So would it be reasonable decision wait on select max 1 sec?

Packets can be lost in which case the node will resend it after a timeout so do not use a value that's just enough for a handshake. You can play a bit with tcpdump , break the connection (unplug the ethernet cable) and see what's happening.

Something like 10-20 seconds should be fine, but this is depends on how important your task is...

The connection to the server should be almost immediately. I think this could be somewhat subjective, but a few seconds should be more than sufficient. For some recent work we used 10 seconds, which has caught all of our cases.

That's up to you really, but I imagine something like 10-20 seconds would be a reasonable time out.

Apache's default KeepAliveTimeout is 15 seconds , so that's one standard you could use.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM