← back to Atmos Game

assets/gen/.venv/lib/python3.12/site-packages/anyio/abc/__pycache__/_sockets.cpython-312.pyc

192 lines

�

c�bjD3��~�UddlmZddlZddlZddlmZddlmZmZm	Z	ddl
mZddlm
Z
ddlmZmZddlmZdd	lmZmZmZd
dlmZd
dlmZmZmZd
dlmZmZmZd
dl m!Z!e"ezezZ#de$d<e%e"e&fZ'de$d<e'e"zZ(de$d<e%e)e'fZ*de$d<e%e)e"fZ+de$d<ed�Z,ejZfddd�											d,d�Z.Gd�de�Z/Gd�de�Z0Gd�dee0�Z1Gd �d!e1�Z2Gd"�d#ee1e0�Z3Gd$�d%ee*e0�Z4Gd&�d'ee)e0�Z5Gd(�d)ee+e0�Z6Gd*�d+ee)e0�Z7y)-�)�annotationsN)�abstractmethod)�Callable�
Collection�Mapping)�AsyncExitStack)�IOBase)�IPv4Address�IPv6Address)�
AddressFamily)�Any�	TypeAlias�TypeVar�)�get_async_backend)�TypedAttributeProvider�TypedAttributeSet�typed_attribute�)�
ByteStream�Listener�UnreliableObjectStream)�	TaskGroupr�
IPAddressType�IPSockAddrType�SockAddrType�
UDPPacketType�UNIXDatagramPacketType�T_RetvalF)�require_connected�
require_boundc�f�t|t�r	tj|��}n?t|tj�r|}n"tdt|�j�d���	|r	|j�|r^	|jtjtjfvr|j�d}n|j�}|st
d��|tjk7r>|j|k7r/t
d|j �d	|jj ����|j|k7r/t
d
|j �d	|jj ����	|j'd�|S#t$rK}|jtj
k(rt
d�|�|rt
d�|�|rt
d�|��d}~wwxYw#t$r}t
d�|�d}~wwxYw#t$rd}Y��2wxYw#t"$r"t|t�r|j%��wxYw)N)�filenoz.the file descriptor does not refer to a socketzthe socket must be connectedz+the socket must be bound to a local addresszexpected an int or socket, got z insteadrz"address family mismatch: expected z, got zsocket type mismatch: expected F)�
isinstance�int�socket�OSError�errno�ENOTSOCK�
ValueError�	TypeError�type�__qualname__�getpeername�family�AF_INET�AF_INET6�getsockname�	AF_UNSPEC�name�
BaseException�detach�setblocking)�
sock_or_fd�	sock_type�addr_familyr r!�sock�exc�
bound_addrs        �i/Users/macstudio3/Projects/atmos-game/assets/gen/.venv/lib/python3.12/site-packages/anyio/abc/_sockets.py�_validate_socketr?s"���*�c�"�	��=�=�
�3�D�
�J��
�
�	.����-�d�:�.>�.K�.K�-L�H�U�
�	
�"��
J�� � �"��
"��;�;�6�>�>�6�?�?�"C�C�!%�!1�!1�!3�A�!6�J�!%�!1�!1�!3�J�� �!N�O�O��&�*�*�*�t�{�{�k�/I��4�[�5E�5E�4F�f��;�;�#�#�$�&��
�
�9�9�	�!��1�)�.�.�1A���	�	���GW�X��
�"�	���U���K��o�
	��y�y�E�N�N�*� �D����#� �!?�@�c�I�� �!N�O�UX�X���
	��,�
J� �!?�@�c�I��
J���
"�!�
�
"�� ���j�#�&��K�K�M�
��sn�E?�)H�,G�<H�?AG3�BH�?	G�AG�G�	G0�G+�+G0�0H�3H�>H�H�H�+H0c��eZdZUdZe�Zded<e�Zded<e�Zded<e�Z	ded	<e�Z
ded
<e�Zded<y)
�SocketAttributea�
    .. attribute:: family
        :type: socket.AddressFamily

        the address family of the underlying socket

    .. attribute:: local_address
        :type: tuple[str, int] | str

        the local address the underlying socket is connected to

    .. attribute:: local_port
        :type: int

        for IP based sockets, the local port the underlying socket is bound to

    .. attribute:: raw_socket
        :type: socket.socket

        the underlying stdlib socket object

    .. attribute:: remote_address
        :type: tuple[str, int] | str

        the remote address the underlying socket is connected to

    .. attribute:: remote_port
        :type: int

        for IP based sockets, the remote port the underlying socket is connected to
    rr/r�
local_addressr%�
local_port�
socket.socket�
raw_socket�remote_address�remote_portN)�__name__�
__module__r-�__doc__rr/�__annotations__rBrCrErFrG��r>rArAcsX���@,�-�F�M�-�"1�"3�M�<�3�%�'�J��'� /� 1�J�
�1�#2�#4�N�L�4�&�(�K��(rMrAc�:�eZdZedd��Zeedd���Zy)�_SocketProviderc�������ddlm�tj�fd�tj��fd�tj
�fd�i}	��jj������fd�|tj<�jjtjtjfvr3�fd�|tj<���d��fd	�|tj<|S#t$rd�Y��wxYw)
Nr)�convert_ipv6_sockaddrc�0���jjS�N)�_raw_socketr/��selfs�r>�<lambda>z2_SocketProvider.extra_attributes.<locals>.<lambda>�s���D�,<�,<�,C�,CrMc�D����jj��SrS�rTr2)�convertrVs��r>rWz2_SocketProvider.extra_attributes.<locals>.<lambda>�s���7�� � �,�,�.�4rMc����jSrS)rTrUs�r>rWz2_SocketProvider.extra_attributes.<locals>.<lambda>�s����0@�0@rMc����SrSrL)�peernames�r>rWz2_SocketProvider.extra_attributes.<locals>.<lambda>�s���rMc�>���jj�dS)NrrYrUs�r>rWz2_SocketProvider.extra_attributes.<locals>.<lambda>�s���� � �,�,�.�q�1rMrc����SrSrL)rGs�r>rWz2_SocketProvider.extra_attributes.<locals>.<lambda>�s���+rM)�_core._socketsrQrAr/rBrErTr.r'rFrr0r1rCrG)rV�
attributesrZr]rGs` @@@r>�extra_attributesz _SocketProvider.extra_attributes�s����E�
�"�"�$C��)�)�,�
�&�&�(@�4
�
�	�/6�t�7G�7G�7S�7S�7U�/V�H�
��9I�J��5�5�6����"�"�}�'<�'<�m�>T�>T�&U�U�6�J��1�1�2��#�&�q�k��:M�
�?�6�6�7����!�	��H�	�s� C+�+C9�8C9c��yrSrLrUs r>rTz_SocketProvider._raw_socket�s��	
rMN)�returnzMapping[Any, Callable[[], Any]])rdrD)rHrIr-�propertyrbrrTrLrMr>rOrO�s0��
����<��
���
rMrOc�"�eZdZdZedd��Zy)�SocketStreamzu
    Transports bytes over a socket.

    Supports all relevant extra attributes from :class:`~SocketAttribute`.
    c��K�t|tjd��}t�j	|��d{���S7��w)aH
        Wrap an existing socket object or file descriptor as a socket stream.

        The newly created socket wrapper takes ownership of the socket being passed in.
        The existing socket must already be connected.

        :param sock_or_fd: a socket object or file descriptor
        :return: a socket stream

        T�r N)r?r&�SOCK_STREAMr�wrap_stream_socket��clsr8r;s   r>�from_socketzSocketStream.from_socket�s7���� �
�F�,>�,>�RV�W��&�(�;�;�D�A�A�A�A���9A�A�AN)r8�socket.socket | intrdrg�rHrIr-rJ�classmethodrnrLrMr>rgrg�s����B��BrMrgc�B�eZdZedd��Zedd��Zedd��Zy)�UNIXSocketStreamc��K�t|tjtjd��}t	�j|��d{���S7��w)aR
        Wrap an existing socket object or file descriptor as a UNIX socket stream.

        The newly created socket wrapper takes ownership of the socket being passed in.
        The existing socket must already be connected.

        :param sock_or_fd: a socket object or file descriptor
        :return: a UNIX socket stream

        TriN)r?r&rj�AF_UNIXr�wrap_unix_stream_socketrls   r>rnzUNIXSocketStream.from_socket�sA���� ���*�*�F�N�N�d�
��'�(�@�@��F�F�F�F���AA�
A�Ac��K�y�w)z�
        Send file descriptors along with a message to the peer.

        :param message: a non-empty bytestring
        :param fds: a collection of files (either numeric file descriptors or open file
            or socket objects)
        NrL)rV�message�fdss   r>�send_fdszUNIXSocketStream.send_fds��������c��K�y�w)a
        Receive file descriptors along with a message from the peer.

        :param msglen: length of the message to expect from the peer
        :param maxfds: maximum number of file descriptors to expect from the peer
        :return: a tuple of (message, file descriptors)
        NrL)rV�msglen�maxfdss   r>�receive_fdszUNIXSocketStream.receive_fds�r}r~N)r8rprdrt)rz�bytesr{zCollection[int | IOBase]rd�None)r�r%r�r%rdztuple[bytes, list[int]])rHrIr-rrrnrr|r�rLrMr>rtrt�s>���G��G� �������rMrtc�R�eZdZdZe				dd��Zedd��Z	d					d	d�Zy)
�SocketListenerz}
    Listens to incoming socket connections.

    Supports all relevant extra attributes from :class:`~SocketAttribute`.
    c��K�t|tjd��}t�j	|��d{���S7��w)a
        Wrap an existing socket object or file descriptor as a socket listener.

        The newly created listener takes ownership of the socket being passed in.

        :param sock_or_fd: a socket object or file descriptor
        :return: a socket listener

        T�r!N)r?r&rjr�wrap_listener_socketrls   r>rnzSocketListener.from_socket�s6���� �
�F�,>�,>�d�S��&�(�=�=�d�C�C�C�C�roc��K�y�w)zAccept an incoming connection.NrLrUs r>�acceptzSocketListener.acceptr}r~Nc��
K�ddlm}t�4�d{���}|�|j|���d{���}	|j	��d{���}|j||��+7�P7�27�#1�d{���7swYyxYw�w)Nr)�create_task_group)�r�r�enter_async_contextr��
start_soon)rV�handler�
task_groupr��stack�streams      r>�servezSocketListener.servest����
	)�!�#�#�u��!�#(�#<�#<�=N�=P�#Q�Q�
��#�{�{�}�,���%�%�g�v�6��	$��Q��-��$�#�#�sT�B�A(�B�A.�A*�A.�A,�A.�(B�*A.�,A.�.B�4A7�5B�<B)r8rprdr�)rdrgrS)r�zCallable[[SocketStream], Any]r�zTaskGroup | Nonerdr�)	rHrIr-rJrrrnrr�r�rLrMr>r�r��sk����D�'�D�
�D��D� �-��-�(,�
7�.�
7�%�
7�
�	
7rMr�c�*�eZdZdZedd��Zdd�Zy)�	UDPSocketz{
    Represents an unconnected UDP socket.

    Supports all relevant extra attributes from :class:`~SocketAttribute`.
    c��K�t|tjd��}t�j	|��d{���S7��w)aI
        Wrap an existing socket object or file descriptor as a UDP socket.

        The newly created socket wrapper takes ownership of the socket being passed in.
        The existing socket must be bound to a local address.

        :param sock_or_fd: a socket object or file descriptor
        :return: a UDP socket

        Tr�N)r?r&�
SOCK_DGRAMr�wrap_udp_socketrls   r>rnzUDPSocket.from_socket#s6���� �
�F�,=�,=�T�R��&�(�8�8��>�>�>�>�roc��HK�|j|||ff��d{���S7��w)z^
        Alias for :meth:`~.UnreliableObjectSendStream.send` ((data, (host, port))).

        N��send)rV�data�host�ports    r>�sendtozUDPSocket.sendto2s&����
�Y�Y��t�T�l�3�4�4�4�4�s�"� �"N)r8rprdr�)r�r�r��strr�r%rdr��rHrIr-rJrrrnr�rLrMr>r�r�s ����?��?�5rMr�c�"�eZdZdZedd��Zy)�ConnectedUDPSocketzy
    Represents an connected UDP socket.

    Supports all relevant extra attributes from :class:`~SocketAttribute`.
    c��K�t|tjd��}t�j	|��d{���S7��w)aV
        Wrap an existing socket object or file descriptor as a connected UDP socket.

        The newly created socket wrapper takes ownership of the socket being passed in.
        The existing socket must already be connected.

        :param sock_or_fd: a socket object or file descriptor
        :return: a connected UDP socket

        TriN)r?r&r�r�wrap_connected_udp_socketrls   r>rnzConnectedUDPSocket.from_socketAs=���� �����"�
��
'�(�B�B�4�H�H�H�H�roN)r8rprdr�rqrLrMr>r�r�:s����I��IrMr�c�2�eZdZdZe				dd��Zdd�Zy)�UNIXDatagramSocketz�
    Represents an unconnected Unix datagram socket.

    Supports all relevant extra attributes from :class:`~SocketAttribute`.
    c��K�t|tjtj�}t	�j|��d{���S7��w)a'
        Wrap an existing socket object or file descriptor as a UNIX datagram
        socket.

        The newly created socket wrapper takes ownership of the socket being passed in.

        :param sock_or_fd: a socket object or file descriptor
        :return: a UNIX datagram socket

        N)r?r&r�rvr�wrap_unix_datagram_socketrls   r>rnzUNIXDatagramSocket.from_socket^s:���� �
�F�,=�,=�v�~�~�N��&�(�B�B�4�H�H�H�H�s�AA�A
�	Ac��DK�|j||f��d{���S7��w)zCAlias for :meth:`~.UnreliableObjectSendStream.send` ((data, path)).Nr�)rVr��paths   r>r�zUNIXDatagramSocket.sendtops�����Y�Y��d�|�,�,�,�,�s� �� N)r8rprdr�)r�r�r�r�rdr�r�rLrMr>r�r�Us6����I�'�I�
�I��I�"-rMr�c�*�eZdZdZe				dd��Zy)�ConnectedUNIXDatagramSocketz�
    Represents a connected Unix datagram socket.

    Supports all relevant extra attributes from :class:`~SocketAttribute`.
    c��K�t|tjtjd��}t	�j|��d{���S7��w)ar
        Wrap an existing socket object or file descriptor as a connected UNIX datagram
        socket.

        The newly created socket wrapper takes ownership of the socket being passed in.
        The existing socket must already be connected.

        :param sock_or_fd: a socket object or file descriptor
        :return: a connected UNIX datagram socket

        TriN)r?r&r�rvr�#wrap_connected_unix_datagram_socketrls   r>rnz'ConnectedUNIXDatagramSocket.from_socket|sA����  ���)�)�6�>�>�T�
��'�(�L�L�T�R�R�R�R�rxN)r8rprdr�rqrLrMr>r�r�us1����S�'�S�
%�S��SrMr�)r8rpr9zsocket.SocketKindr:zsocket.AddressFamilyr �boolr!r�rdrD)8�
__future__rr(r&�abcr�collections.abcrrr�
contextlibr�ior	�	ipaddressr
rr�typingr
rr�_core._eventloopr�_core._typedattrrrr�_streamsrrr�_tasksrr�rrK�tupler%rrr�rrrr3r?rArOrgrtr�r�r�r�r�rLrMr>�<module>r�s���"��
��9�9�%��.� �*�*�0���
C�B����,�{�:�
�y�:�!�#�s�(�O��	�+�(�3�.��i�.� ���!6�7�
�y�7�$)�%��*�$5��	�5��:���)/�(8�(8�B�
$��
B�#�B� �B�&�B�
�B��
B��B�J&)�'�&)�R#
�,�#
�LB�:��B�.$�|�$�N)7�X�l�+�_�)7�X5�&�}�5��5�<I�/��6��I�6-��1�2�O�-�@S�"8��"?��SrM