
    Mh                         d dl Z d dlZd dlZd dlmZ d dlmZ d e j        dfdZd Z	d Z
e j        fdZd Zd e j        dfd	ZdS )
    N)log)hide_thread_from_debuggerc                    |dk    sJ | d} |d}	 t                      }|dk    rt          j        dk    r,|                    t          j        t          j        d           nD	 |                    t          j        t          j        d           n# t          t          f$ r Y nw xY w|
                    | |f           ||                    |           |                    |           n## t          $ r |                                  w xY w|S )z9Return a local server socket listening on the given port.r   Nz	127.0.0.1win32   )	_new_socksysplatform
setsockoptsocket
SOL_SOCKETSO_EXCLUSIVEADDRUSESO_REUSEADDRAttributeErrorOSErrorbind
settimeoutlisten	Exceptionclose)hostportbacklogtimeoutservers        V/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/debugpy/common/sockets.pycreate_serverr      s/    Q;;;;||199 |w&&!!&"3V5OQRSSSS%%f&79LaPPPP&0   DT4L!!!g&&&g    Ms1   AC* #+B C* B# C* "B##AC* * D
c                      t                      S )zAReturn a client socket that may be connected to a remote address.)r        r   create_clientr!   -   s    ;;r    c                     t          j         t           j        t           j        t           j                  } 	 |                     t           j        t           j        d           n# t          t          f$ r Y nw xY w	 |                     t           j        t           j	        d           n# t          t          f$ r Y nw xY w	 |                     t           j        t           j
        d           n# t          t          f$ r Y nw xY w	 |                     t           j        t           j        d           n# t          t          f$ r Y nw xY w| S )Nr         )r   AF_INETSOCK_STREAMIPPROTO_TCPr   r   SO_KEEPALIVEr   r   TCP_KEEPIDLETCP_KEEPINTVLTCP_KEEPCNTsocks    r   r   r   2   sF   =);V=OPPD)6+>BBBBG$   *F,?CCCCG$   *F,@!DDDDG$   *F,>BBBBG$   KsG   +A" "A65A6:+B& &B:9B:>+C* *C>=C>+D. .EEc                 0    |                      |           dS )zShut down the given socket.N)shutdown)r-   hows     r   	shut_downr1   L   s    MM#r    c                 p    	 t          |            n# t          $ r Y nw xY w|                                  dS )zShutdown and close the socket.N)r1   r   r   r,   s    r   close_socketr3   Q   sE    $   JJLLLLLs    
c                 z    |dk    sJ 	 t          ||||          n'# t          $ r t          j        d ||           Y nw xY w                                \  }}t          j        d ||            fd}t          j        |          }d|_        t          |           |
                                 S )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                      	 	                                  \  } \  }}n# t          t          j        f$ r Y d S w xY wt	          j        d||            |            \)NTz.Accepted incoming {0} connection from {1}:{2}.)acceptr   r   errorr   info)r-   
other_host
other_porthandlerlistenernames      r   accept_workerzserve.<locals>.accept_workerl   s    	191B1B..z::V\*    H@	   GDMMM	s    99)targetT)r   r   r   reraise_exceptiongetsocknamer8   	threadingThreaddaemonr   start)	r=   r;   r   r   r   r   r>   threadr<   s	   ``      @r   serverG   Z   s     Q;;;;
 tWg>> 
 
 
FdTX	
 	
 	
 	
 	

 %%''JD$HCT4QUVVV        ]333FFMf%%%
LLNNNOs     !AA)r   r	   rB   debugpy.commonr   debugpy.common.utilr   	SOMAXCONNr   r!   r   	SHUT_RDWRr1   r3   rG   r   r    r   <module>rL      s   
  



           9 9 9 9 9 9 (8$    @  
  4 (    
   %&v/? ' ' ' ' ' 'r    