def _set_keep_alive(self):
if not self._config.ENABLE_KEEP_ALIVE:
return
stream_socket = self._stream.socket
stream_socket.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
if platform.system().lower() == 'linux':
stream_socket.setsockopt(socket.SOL_TCP, socket.TCP_KEEPIDLE, self._config.KEEP_ALIVE_OPT['timeout'])
stream_socket.setsockopt(socket.SOL_TCP, socket.TCP_KEEPINTVL, self._config.KEEP_ALIVE_OPT['interval'])
stream_socket.setsockopt(socket.SOL_TCP, socket.TCP_KEEPCNT, self._config.KEEP_ALIVE_OPT['count'])
评论列表
文章目录