tcp_server.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:pycon2016 作者: nhudinhtuan 项目源码 文件源码
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'])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号