
    ;e                        d Z ddlZdadad Z G d d          Z G d d          ZddZej        dfd	Z	d
 Z
d Zd Zd Zd Zd Zej        Zej        Zej        Zej        Zej        Zej        ZdZdZ eed          r	ej        ZdS dS )z8Mock socket module used by the smtpd and smtplib tests.
    Nc                 
    | a d S N)_reply_data)lines    '/usr/lib/python3.11/test/mock_socket.py
reply_withr      s    KKK    c                   &    e Zd ZdZd ZddZd ZdS )MockFilez8Mock file object returned by MockSocket.makefile().
    c                     || _         d S r   )lines)selfr   s     r   __init__zMockFile.__init__   s    


r	   c                     | j                             d          dz   }|dk    r-| j                             d||d                    |d |         }|S )Nr      
)r   popinsert)r   limitresults      r   readlinezMockFile.readline   sV    ""W,A::Jab!1222FUF^Fr	   c                     d S r    r   s    r   closezMockFile.close       r	   N)r   )__name__
__module____qualname____doc__r   r   r   r   r	   r   r   r      sP                  r	   r   c                       e Zd ZdZddZd ZddZd Zd Zd Z	d	 Z
dd
Zd Zd Zd Zd Zd ZddZddZddZd Zd Zd ZdS )
MockSocketz8Mock socket object used by smtpd and smtplib tests.
    Nc                     || _         g | _        g | _        t          r!| j                            t                     d ad | _        d | _        d S r   )familyoutputr   r   appendconntimeout)r   r%   s     r   r   zMockSocket.__init__&   sL    
 	Jk***K	r	   c                 :    | j                             |           d S r   )r   r'   )r   r   s     r   
queue_recvzMockSocket.queue_recv1   s    
$r	   c                 @    | j                             d          dz   }|S )Nr   r   )r   r   )r   bufsizeflagsdatas       r   recvzMockSocket.recv4   s    z~~a  7*r	   c                     dS Nr   r   r   s    r   filenozMockSocket.fileno8       qr	   c                 4    |t           | _        d S || _        d S r   )_defaulttimeoutr)   )r   r)   s     r   
settimeoutzMockSocket.settimeout;   s    ?*DLLL"DLLLr	   c                     | j         S r   r)   r   s    r   
gettimeoutzMockSocket.gettimeoutA   s
    |r	   c                     d S r   r   )r   leveloptnamevalues       r   
setsockoptzMockSocket.setsockoptD   r   r	   c                     dS r2   r   )r   r<   r=   buflens       r   
getsockoptzMockSocket.getsockoptG   r4   r	   c                     d S r   r   )r   addresss     r   bindzMockSocket.bindJ   r   r	   c                 :    t                      | _        | j        dfS )Nc)r#   r(   r   s    r   acceptzMockSocket.acceptM   s    LL	y#~r	   c                     dS )N)z0.0.0.0r   r   r   s    r   getsocknamezMockSocket.getsocknameQ   s    ~r	   c                     d S r   r   )r   flags     r   setblockingzMockSocket.setblockingT   r   r	   c                     d S r   r   )r   backlogs     r   listenzMockSocket.listenW   r   r	   rr   c                 .    t          | j                  }|S r   )r   r   )r   moder-   handles       r   makefilezMockSocket.makefileZ   s    $*%%r	   c                 b    || _         | j                            |           t          |          S r   lastr&   r'   lenr   r/   r.   s      r   sendallzMockSocket.sendall^   +    	4   4yyr	   c                 b    || _         | j                            |           t          |          S r   rW   rZ   s      r   sendzMockSocket.sendc   r\   r	   c                     dS )N)zpeer-addressz	peer-portr   r   s    r   getpeernamezMockSocket.getpeernameh   s    ,,r	   c                     d S r   r   r   s    r   r   zMockSocket.closek   r   r	   c                     d S r   r   )r   hosts     r   connectzMockSocket.connectn   r   r	   r   )rQ   r   )r   r   r    r!   r   r+   r0   r3   r7   r:   r?   rB   rE   rH   rJ   rM   rP   rU   r[   r^   r`   r   rd   r   r	   r   r#   r#   #   sY        	 	 	 	          # # #                       
   
- - -      r	   r#   c                      t          |           S r   )r#   )r%   typeprotos      r   socketrh   r   s    fr	   c                     	 t          | d                   }n# t          $ r t          w xY wt                      }|t          j        u rt                      }|                    |           |S )N   )int
ValueErrorerrorr#   socket_module_GLOBAL_DEFAULT_TIMEOUTgetdefaulttimeoutr7   )rD   r)   source_addressint_portmss        r   create_connectionrt   u   sq    wqz??   	B-777#%%MM'Is    *c                 
    | a d S r   r6   r9   s    r   setdefaulttimeoutrw      s    OOOr	   c                      t           S r   rv   r   r	   r   rp   rp      s    r	   c                      dS N r   r   r	   r   getfqdnr|          2r	   c                      d S r   r   r   r	   r   gethostnamer      s    Dr	   c                     dS rz   r   )names    r   gethostbynamer      r}   r	   c                  $    t          j        | i |S r   )rn   getaddrinfo)argskws     r   r   r      s    $d1b111r	   AF_UNIX)NNN)r!   rh   rn   r6   r   r   r   r#   ro   rt   rw   rp   r|   r   r   r   gaierrorrm   AF_INETAF_INET6SOCK_STREAM
SOL_SOCKETSO_REUSEADDRhasattrr   r   r	   r   <module>r      s        
  
        L L L L L L L L^    (5'L%)
 
 
 
  
    	 	 	  2 2 2 ! (? 

!'

7=)$$ $#GGG$ $r	   