File: //var/opt/nydus/ops/mysql/connector/__pycache__/network.cpython-39.pyc
a
�,�h�m � @ sJ d Z ddlZddlZddlZddlZddlmZmZ ddlm Z ddl
mZmZm
Z
mZmZmZ z2ddlZejejejejd�Zeed�o�ejZW n ey� dZdZY n0 d d
lmZmZmZmZ dZ dZ!d
Z"dZ#e$e%d�dd�Z&G dd� de�Z'G dd� de'�Z(G dd� de(�Z)G dd� de�Z*G dd� de*�Z+G dd� de*�Z,dS )zGModule implementing low-level socket communication with MySQL servers.
� N)�ABC�abstractmethod)�deque)�Any�Deque�List�Optional�Tuple�Union)�TLSv1�TLSv1.1�TLSv1.2�TLSv1.3�HAS_TLSv1_3F� )�InterfaceError�NotSupportedError�OperationalError�ProgrammingError�2 i��� � � )�err�returnc C s | j st| �S | j � d| j� �S )z`Reformat the IOError error message.
This function reformats the IOError error message.
� )�errno�str�strerror)r � r �J/opt/nydus/tmp/pip-target-wkfpz8uv/lib64/python/mysql/connector/network.py�_strioerrorE s r c @ sP e Zd ZdZed ejeeee ee dd�dd��Z
eejeed�dd��ZdS )
�
NetworkBrokeraP Broker class interface.
The network object is a broker used as a delegate by a socket object. Whenever the
socket wants to deliver or get packets to or from the MySQL server it needs to rely
on its network broker (netbroker).
The netbroker sends `payloads` and receives `packets`.
A packet is a bytes sequence, it has a header and body (referred to as payload).
The first `PACKET_HEADER_LENGTH` or `COMPRESSED_PACKET_HEADER_LENGTH`
(as appropriate) bytes correspond to the `header`, the remaining ones represent the
`payload`.
The maximum payload length allowed to be sent per packet to the server is
`MAX_PAYLOAD_LENGTH`. When `send` is called with a payload whose length is greater
than `MAX_PAYLOAD_LENGTH` the netbroker breaks it down into packets, so the caller
of `send` can provide payloads of arbitrary length.
Finally, data received by the netbroker comes directly from the server, expect to
get a packet for each call to `recv`. The received packet contains a header and
payload, the latter respecting `MAX_PAYLOAD_LENGTH`.
N��sock�address�payload�
packet_number�compressed_packet_numberr c C s dS )a� Send `payload` to the MySQL server.
If provided a payload whose length is greater than `MAX_PAYLOAD_LENGTH`, it is
broken down into packets.
Args:
sock: Object holding the socket connection.
address: Socket's location.
payload: Packet's body to send.
packet_number: Sequence id (packet ID) to attach to the header when sending
plain packets.
compressed_packet_number: Same as `packet_number` but used when sending
compressed packets.
Raises:
:class:`OperationalError`: If something goes wrong while sending packets to
the MySQL server.
Nr )�selfr# r$ r% r&