
    g                        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  SSKJr  SSKJr  \R                   S:  a  SSKr\R$                  \R&                  l        SSSSS.S	\
\   S
\	\
\      S\	\   S\	\   S\	\R,                     S\R
                  4S jjr SS\R,                  S\\\\\4         S\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Union   )
_staggered)AddrInfoType)         )local_addr_infoshappy_eyeballs_delay
interleaveloop
addr_infosr   r   r   r   returnc                  ^^^^^#    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5      I Sh  vN n  O2   O/[        R                  " UUU4S jU  5       U5      I Sh  vN u  n  n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NJ! [
        [        4 a     GMv  f = f GN5s  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   `   >#    U  H#  n[         R                  " [        TTUT5      v   M%     g 7fN)	functoolspartial_connect_sock).0addrinfocurrent_loop
exceptionsr   s     ]/Users/Alptekin/Desktop/izin_takip/venv/lib/python3.13/site-packages/aiohappyeyeballs/impl.py	<genexpr>#start_connection.<locals>.<genexpr>Z   s8       !+H !!!<XGW  !+s   +.r   c              3   @   >#    U  H  n[        U5      T:H  v   M     g 7fr   str)r   excmodels     r   r   r   l   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   q   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   w   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)   r   staggered_racer"   allformatjoinr(   r*   )r   r   r   r   r   single_addr_infosockr   _subr#   all_exceptionsfirst_exceptionmsgr   r   r+   r$   s    `            @@@@r   start_connectionr=      s    L ! L //1:!+'J,>
**:B
$(D;=J#'7"H* *h8H   # &44 !+	 !
 

a |)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"
 Km !'* 
 DB "NJss   A!G1)G:G;G?+G1*G+G1<G"G1C.G( G1GGG1GG1"G1(G..G1r   	addr_infoc                 z  #    / nUR                  U5        Uu  pVpxn	Sn
 [        R                  " XVUS9n
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$ ! [         aS  nSU< SUR
                  R                  5        3n[	        UR                  U5      nUR                  U5         SnAM  SnAff = f Ni! [        [        4 aP  nUR                  U5        U
b6   U
R                  5         e ! [         a  nUR                  U5        e SnAff = fe SnAf  U
b6   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)z$Create, bind and connect one socket.N)familytypeprotoFz*error while attempting to bind on address z: z&no matching local address with family=z found)appendsocketsetblockingbindr)   strerrorlowerr*   popsock_connectr-   close)r   r   r>   r   my_exceptionsr@   type_rB   r8   addressr7   lfamilyladdrr#   r<   es                   r   r   r      s     9;Mm$'0$F5WD,*}}FeD'+;'Aq$
.IIe$ ,<  !'++--!$KF9F"STT...& &*)
]C  .##()2<<--/02 
 "#))S1C!((--. 	/'" S!

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

 	  $$Q' 	%))
]s   F;:D B4+?D *D+D 0F;4
D>ADD DD F0&E1;EE1
E-E((E--E11F0:F
F0
F,F''F,,F00F3 3F88F;	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OrderedDictrC   listvaluesextend	itertoolschainfrom_iterablezip_longest)rR   rS   addrinfos_by_familyaddrr@   addrinfos_lists	reordereds          r   r1   r1      s     	!  a,*,'#**40	 
 .5578O$&I!A%+,L.H1.LMNA?!;a!??@ ..y/D/Do/VW 
     r   )r   )__doc__r.   rY   r   r^   rD   systypingr   r   r   r    r   typesr	   version_infoasyncio.futuresTimeoutErrorfuturesfloatintAbstractEventLoopr=   r)   r-   r   r1   rV   rf   r   <module>rs      sU         
 2 2  i #*#7#7GOO  :>,0 $04o&o x56o #5/	o
 o 7,,
-o ]]ol :>	7*

#
#7*T% 56787* 7* x56	7*
 ]]7*v JK%CF	,rf   