if  tcp_keepalive:
                # 启用KeepAlive选项
                sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
                # TCP_KEEPCNT:判定断开前的KeepAlive探测次数 
                if tcp_keepcnt:
                    sock.setsockopt(socket.SOL_TCP, socket.TCP_KEEPCNT,
                                    tcp_keepcnt)
                # TCP_KEEPIDLE: 开始首次KeepAlive探测前的TCP空闲时间
                if tcp_keepidle:
                    sock.setsockopt(socket.SOL_TCP, socket.TCP_KEEPIDLE,
                                    tcp_keepidle)
                # TCP_KEEPINTVL:两次KeepAlive探测间的时间间隔
                if tcp_keepintvl:
                    sock.setsockopt(socket.SOL_TCP, socket.TCP_KEEPINTVL,
                                    tcp_keepintvl)

相关文章:

猜你喜欢
  • 2021-07-21
  • 2021-06-24
  • 2021-06-13
  • 2022-12-23
  • 2022-02-02
  • 2021-09-25
  • 2021-06-26
相关资源
相似解决方案