if (setsockopt(CastToSocket(socket), IPPROTO_TCP, TCP_KEEPIDLE, &val, sizeof(val)) < 0) {
return false;
}
/* Send next probes after the specified interval. Note that we set the
* delay as interval / 3, as we send three probes before detecting
* an error (see the next setsockopt call). */
val = interval / count;
if (val == 0) val = 1;
if (setsockopt(CastToSocket(socket), IPPROTO_TCP, TCP_KEEPINTVL, &val, sizeof(val)) < 0) {
return false;
}
/* Consider the socket in error state after three we send three ACK
* probes without getting a reply. */
val = count;
if (setsockopt(CastToSocket(socket), IPPROTO_TCP, TCP_KEEPCNT, &val, sizeof(val)) < 0) {
return false;
}