| | |
| | | @classmethod |
| | | def __create_client(cls, client_type, rid): |
| | | client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # 生成socket,连接server |
| | | client.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, True) |
| | | # client.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, True) |
| | | # client.ioctl(socket.SIO_KEEPALIVE_VALS, (1, 60 * 1000, 30 * 1000)) |
| | | client.connect(cls.ip_port) |
| | | client.send(SendResponseSkManager.format_response( |
| | |
| | | json.dumps({"type": "heart", "client_id": client_id}).encode('utf-8'))) |
| | | # print("心跳信息发送成功", client_id) |
| | | except Exception as e: |
| | | logging.error("错误") |
| | | print("心跳信息发送失败", _type, client_id) |
| | | logging.exception(e) |
| | | if _type == CLIENT_TYPE_TRADE: |