
    h                         S SK r S SKrS SKrS SKJr  S SKJr  S rS rS r	S r
S \ R                  S4S jrSS	 jrSS
 jr\ R                  4S jrS rS \ R                  S4S jrg)    N)log)hide_thread_from_debuggerc                  V    [         R                   " [         R                  [         R                  5      n U R                  [         R                  [         R
                  S5        U R                  S5        U R                  5         g! [         R                  [        [        4 a     gf = f)z'Check if we can bind to IPv4 localhost.   )	127.0.0.1r   TF)socketAF_INETSOCK_STREAM
setsockopt
SOL_SOCKETSO_REUSEADDRbindcloseerrorOSErrorAttributeErrorsocks    iC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\debugpy/common/sockets.pycan_bind_ipv4_localhostr      ss    }}V^^V-?-?@))6+>+>B		"#

LL'>2    BB B('B(c                  V    [         R                   " [         R                  [         R                  5      n U R                  [         R                  [         R
                  S5        U R                  S5        U R                  5         g! [         R                  [        [        4 a     gf = f)z'Check if we can bind to IPv6 localhost.r   )::1r   TF)r   AF_INET6r
   r   r   r   r   r   r   r   r   r   s    r   can_bind_ipv6_localhostr      sr    }}V__f.@.@A))6+>+>B		*

LL'>2 r   c                  D    [        5       (       a  g[        5       (       a  gg)zvGet the default localhost address.
Defaults to IPv4 '127.0.0.1', but falls back to IPv6 '::1' if IPv4 is unavailable.
r   r   )r   r        r   get_default_localhostr   $   s#    
       r   c                      U R                  5       SS u  pX4$ ! [         a*  n[        R                  " S5        [	        SU 35      UeSnAff = f)z&Gets the socket address host and port.N   zFailed to get socket address:zFailed to get socket address: )getsockname	Exceptionr   swallow_exceptionRuntimeError)r   hostportexcs       r   get_addressr)   4   sa    L%%'+

 :	  L=>;C5ABKLs    
A%A		Ac                 F   US:  d   eU c
  [        5       n Uc  SnU R                  S5      S:  n [        U5      nUS:w  at  [        R                  S:X  a0  UR                  [        R                  [        R                  S5        O0 UR                  [        R                  [        R                  S5        UR                  X45        Ub  UR                  U5        UR                  U5        U$ ! [        [        4 a     NKf = f! [         a    WR!                  5         e f = f)z9Return a local server socket listening on the given port.r   :r   win32)r   count	_new_socksysplatformr   r   r   SO_EXCLUSIVEADDRUSEr   r   r   r   
settimeoutlistenr#   r   )r&   r'   backlogtimeoutipv6servers         r   create_serverr8   >   s
    Q;;|$&|::c?QD419 ||w&!!&"3"3V5O5OQRS%%f&7&79L9LaP 	TL!g&g M '0   s0   AD /C. 57D .D>D  DD D c                     [        U 5      $ )zAReturn a client socket that may be connected to a remote address.)r.   )r6   s    r   create_clientr:   _   s    T?r   c                    U (       a  [         R                  O[         R                  n[         R                   " U[         R                  [         R                  5      n UR                  [         R                  [         R                  S5         UR                  [         R                  [         R                  S5         UR                  [         R                  [         R                  S5         UR                  [         R                  [         R                  S5        U$ ! [        [        4 a     Nf = f! [        [        4 a     Nf = f! [        [        4 a     Npf = f! [        [        4 a     U$ f = f)Nr         )r   r   r	   r
   IPPROTO_TCPr   r   SO_KEEPALIVEr   r   TCP_KEEPIDLETCP_KEEPINTVLTCP_KEEPCNT)r6   address_familyr   s      r   r.   r.   d   s"   (,V__&..N==););V=O=OPD))6+>+>B**F,?,?C**F,@,@!D**F,>,>B K G$  G$  G$  G$ KsH   /D /D4 =/E
 -/E  D10D14EE
EE E43E4c                 &    U R                  U5        g)zShut down the given socket.N)shutdown)r   hows     r   	shut_downrG      s    MM#r   c                 \     [        U 5        U R                  5         g! [         a     Nf = f)zShutdown and close the socket.N)rG   r#   r   r   s    r   close_socketrI      s-    $ 	JJL  s    
++c                 L  ^ ^^ US:  d   e [        X#XE5      m[	        T5      u  p#[        R
                  " ST X#5        UUU 4S jn[        R                  " US9nSUl        [        U5        UR                  5         T$ ! [         a    [        R                  " ST X#5         Nf = f)zAccepts TCP connections on the specified host and port, and invokes the
provided handler function for every new connection.

Returns the created server socket.
r   z8Error listening for incoming {0} connections on {1}:{2}:z4Listening for incoming {0} connections on {1}:{2}...c                     >   TR                  5       u  pUS S u  p#[        R
                  " STUU5        T" U 5        M=  ! [        [        R                  4 a     g f = f)Nr!   z.Accepted incoming {0} connection from {1}:{2}.)acceptr   r   r   r   info)r   address
other_host
other_porthandlerlistenernames       r   accept_workerserve.<locals>.accept_worker   sl     ( 1)0!&

 HH@	 DM  V\\* s   A   AA)targetT)r8   r#   r   reraise_exceptionr)   rM   	threadingThreaddaemonr   start)	rS   rQ   r&   r'   r4   r5   rT   threadrR   s	   ``      @r   server]      s     Q;;
 W>
 X&JDHHCT4V" ]3FFMf%
LLNO;  
Fd	

s   A> >"B#"B#)F)r   r/   rX   debugpy.commonr   debugpy.common.utilr   r   r   r   r)   	SOMAXCONNr8   r:   r.   	SHUT_RDWRrG   rI   r]   r   r   r   <module>rb      sr   
  
   9

  (8(8$ B
6 (( 
 %&v/?/? (r   