
    h%                        S r SSKrSSKrSSKrSSKrSSKrSSKrSSKJrJ	r	J
r
JrJr  SSKJr  SSKJrJr  SSSSSS.S\
\   S	\	\
\      S
\	\   S\	\   S\	\R(                     S\	\   S\R                  4S jjr   SS\R(                  S\\\\\4         S\S	\	\
\      S\	\\R                        S\	\   S\R                  4S jjr SS\
\   S\S\\   4S jjrg)zBase implementation.    N)ListOptionalSequenceSetUnion   )
_staggered)AddrInfoTypeSocketFactoryType)local_addr_infoshappy_eyeballs_delay
interleaveloopsocket_factory
addr_infosr   r   r   r   r   returnc          	      l  ^^^^^^^#    U=m(       d  [         R                  " 5       m[        U 5      S:H  nUb  Uc  SnU(       a  U(       d  [        X5      n Sn/ mUb  U(       a#  U  H  n [	        TTUTST5      I Sh  vN n  O   O[        5       m [        R                  " UUUUU4S jU  5       U5      I Sh  vN u  n  n	T H<  n
XLd  M	  [        R                  " [        5         U
R                  5         SSS5        M>     SmUGc  T VVs/ s H  o  H  oPM     M     nnn US   n[        U5      S:X  a  Ue[        U5      m[        U4S jU 5       5      (       a  UeSR                  SR!                  S U 5       5      5      n[#        U[        5      (       a3  UR$                  m[        U4S	 jU 5       5      (       a  [        TU5      eO7[#        U[
        5      (       a"  [        S
 U 5       5      (       a  [        U5      e[        U5      eU$  GN! [
        [        4 a     GM  f = f GNy! , (       d  f       GM  = f! T HN  n
XLd  M	  [        R                  " [        5         U
R                  5         SSS5        M>  ! , (       d  f       MM  = f   Smf = fs  snnf ! SnSmf = f7f)a  
Connect to a TCP server.

Create a socket connection to a specified destination.  The
destination is specified as a list of AddrInfoType tuples as
returned from getaddrinfo().

The arguments are, in order:

* ``family``: the address family, e.g. ``socket.AF_INET`` or
    ``socket.AF_INET6``.
* ``type``: the socket type, e.g. ``socket.SOCK_STREAM`` or
    ``socket.SOCK_DGRAM``.
* ``proto``: the protocol, e.g. ``socket.IPPROTO_TCP`` or
    ``socket.IPPROTO_UDP``.
* ``canonname``: the canonical name of the address, e.g.
    ``"www.python.org"``.
* ``sockaddr``: the socket address

This method is a coroutine which will try to establish the connection
in the background. When successful, the coroutine returns a
socket.

The expected use case is to use this method in conjunction with
loop.create_connection() to establish a connection to a server::

        socket = await start_connection(addr_infos)
        transport, protocol = await loop.create_connection(
            MyProtocol, sock=socket, ...)
r   Nc           
   3   d   >#    U  H%  n[         R                  " [        TTUTTT5      v   M'     g 7fN)	functoolspartial_connect_sock).0addrinfocurrent_loop
exceptionsr   open_socketsr   s     G/var/www/html/env/lib/python3.13/site-packages/aiohappyeyeballs/impl.py	<genexpr>#start_connection.<locals>.<genexpr>X   sA       %/ %%%$" ($&  %/s   -0r   c              3   @   >#    U  H  n[        U5      T:H  v   M     g 7fr   str)r   excmodels     r   r   r    ~   s     CNSs3x5(Ns   zMultiple exceptions: {}z, c              3   8   #    U  H  n[        U5      v   M     g 7fr   r"   r   r$   s     r   r   r       s     A.3c#hh.s   c              3   p   >#    U  H+  n[        U[        5      =(       a    UR                  T:H  v   M-     g 7fr   )
isinstanceOSErrorerrno)r   r$   first_errnos     r   r   r       s0      #1C #30MSYY+5MM#1s   36c              3   B   #    U  H  n[        U[        5      v   M     g 7fr   )r)   RuntimeErrorr'   s     r   r   r       s      G=KcJsL11^s   )asyncioget_running_looplen_interleave_addrinfosr   r.   r*   setr	   staggered_race
contextlibsuppresscloser#   allformatjoinr)   r+   )r   r   r   r   r   r   single_addr_infosockr   _ssubr$   all_exceptionsfirst_exceptionmsgr   r   r,   r%   r   s    `   `          @@@@@r   start_connectionrC      s    N ! L //1:!+'J,>
**:B
$(D;=J#'7"H* $"   # ,/5	 )88  %/ %  JD!Q0 "=#,,W5	 65 "  L|)3C#s#s#C!	,Q/O>"a'%% O,CNCCC)) 066IIA.AA
 ow77"1"7"7K #1   &k377	
  >>3 G=KG D D 's++ cl"
 Kc !'* 
4 65 "=#,,W5	 6555 "  L DB "NJs   A!J4+H>H?HJ4(I
 ;H4<I
 J4J4)H7:J4J%%J4)C.J+ J4HH1,J40H11J44I
 7
I		J4
J"J"0J	
J"
JJ""	J4+J11J4r   	addr_infor   c                   #    / nUR                  U5        Uu  pxpnSn Ub	  U" U5      nO[        R                  " XxU	S9nUb  UR                  U5        UR                  S5        UbN  U H!  u  n    pX:w  a  M   UR	                  U5          O)   U(       a  UR                  5       e[        SU< S35      eU R                  X5      I Sh  vN   US=p$ ! [
         a\  nSU< SUR                  =(       d    SR                  5        3n[        UR                  U5      nUR                  U5         SnAM  SnAff = f Nr! [        [
        4 ad  nUR                  U5        UbJ  Ub  UR                  U5         UR                  5         e ! [
         a  nUR                  U5        e SnAff = fe SnAf  UbJ  Ub  UR                  U5         UR                  5         e ! [
         a  nUR                  U5        e SnAff = fe = f! S=pf = f7f)	aU  
Create, bind and connect one socket.

If open_sockets is passed, add the socket to the set of open sockets.
Any failure caught here will remove the socket from the set and close it.

Callers can use this set to close any sockets that are not the winner
of all staggered tasks in the result there are runner up sockets aka
multiple winners.
N)familytypeprotoFz*error while attempting to bind on address z:  z&no matching local address with family=z found)appendsocketaddsetblockingbindr*   strerrorlowerr+   popsock_connectr.   remover7   )r   r   rD   r   r   r   my_exceptionsrF   type_rH   r=   addressr<   lfamilyladdrr$   rB   es                     r   r   r      s4    $ 9;Mm$'0$F5WD5*%!),D==%HD#T"'+;'Aq$
.IIe$ ,<  !'++--!$KF9F"STT.... &*)
]K  .##()2LL.B5578: 
 "#))S1C!((--. 	/'" 
S!'##D)

 	  $$Q' 		'##D)

 	  $$Q' 	%))
]s   HAD? :C?D? 
D=D? H
D:AD5/D? 5D::D? ?H(F.8F	F.	
F*F%%F**F..HGH
G=&G88G==HH H		H	addrinfosfirst_address_family_countc                    [         R                  " 5       nU  H$  nUS   nXB;  a  / X$'   X$   R                  U5        M&     [        UR	                  5       5      n/ nUS:  a%  UR                  US   SUS-
   5        US   SUS-
  2	 UR                  S [        R                  R                  [        R                  " U6 5       5       5        U$ )z-Interleave list of addrinfo tuples by family.r   r   Nc              3   0   #    U  H  nUc  M  Uv   M     g 7fr    )r   as     r   r   (_interleave_addrinfos.<locals>.<genexpr>   s      WA 	
Ws   	)
collectionsOrderedDictrJ   listvaluesextend	itertoolschainfrom_iterablezip_longest)rZ   r[   addrinfos_by_familyaddrrF   addrinfos_lists	reordereds          r   r2   r2      s     	!  a,*,'#**40	 
 .5578O$&I!A%+,L.H1.LMNA?!;a!??@ ..y/D/Do/VW 
     )NNN)r   )__doc__r/   ra   r5   r   rf   rK   typingr   r   r   r   r   rI   r	   typesr
   r   floatintAbstractEventLooprC   r*   r.   r   r2   r^   rn   r   <module>ru      sz          7 7  2 :>,0 $0426K&K x56K #5/	K
 K 7,,
-K ./K ]]Kd :>1526K*

#
#K*T% 5678K* K* x56	K*
 3v}}-.K* ./K* ]]K*^ JK%CF	,rn   