1
0
mirror of https://github.com/prirun/p50em.git synced 2026-02-27 00:39:52 +00:00

TCP_KEEPALIVE timer not supported on OSX

This commit is contained in:
Jim Wilcoxson
2020-05-27 18:49:35 -04:00
parent 9c6722ffc5
commit 43bbf3cd8f

View File

@@ -911,10 +911,12 @@ int devamlc (int class, int func, int device) {
optval = 1;
if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &optval, sizeof(optval)) == -1)
perror("unable to set TCP_NODELAY");
#ifndef __APPLE__
/* Set 600 second keepalive idle time for this socket */
optval = 600;
if (setsockopt(fd, 6 /* TCP */, TCP_KEEPIDLE, &optval, sizeof(optval)) == -1)
if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &optval, sizeof(optval)) == -1)
perror("unable to set TCP_KEEPIDLE");
#endif
/* ... and turn on keepalive */
optval = 1;
if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &optval, sizeof(optval)) == -1)