Question

I'm trying to port some code over to OSX - it appears that setsockopt has a few differences from Linux. The one I've found and corrected so far is using TCP_KEEPALIVE instead of TCP_KEEPIDLE.

What is the equivalent to TCP_USER_TIMEOUT for OSX?

Using TCP_USER_TIMEOUT fails to compile and prints an undeclared identifier error

Was it helpful?

Solution

I find a macro named "TCP_CONNECTIONTIMEOUT" in tcp.h. I use it to replace TCP_USER_TIMEOUT on Mac. It works well. You may try it.

OTHER TIPS

Another possible option is TCP_RXT_CONNDROPTIME from the same header:

#define TCP_RXT_CONNDROPTIME    0x80    /* time after which tcp retransmissions will be 
                                         * stopped and the connection will be dropped
                                         */

I've found this weird commit where there are three implementations provided for TCP_USER_TIMEOUT:

  • Linux: TCP_USER_TIMEOUT is set manually (seems like this code is quite outdated);
  • Darwin: TCP_RXT_CONNDROPTIME is used;
  • Win: no implementation provided.

This commit might be a clue, but I haven't tested it myself. I just hope that this information could be helpful to someone.

Check TCP_USER_TIMEOUT and TCP_CONNECTIONTIMEOUT descriptions in the Linux man and BSD man - they doesn't seem to be very similar.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top