This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setTcpKeepalive(SOCKET &sockfd) | |
{ | |
const uint32_t keepaliveIntervalSec = 10; | |
#ifdef _WIN32 | |
tcp_keepalive keepaliveParams; | |
DWORD ret = 0; | |
keepaliveParams.onoff = 1; | |
keepaliveParams.keepaliveinterval = keepaliveParams.keepalivetime = keepaliveIntervalSec * 1000; | |
WSAIoctl(sockfd, SIO_KEEPALIVE_VALS, &keepaliveParams, sizeof(keepaliveParams), NULL, 0, &ret, NULL, NULL); |