B
    H/\                 @   s   d Z ddlmZ ddlmZ ddlmZ er:ddlmZ nddlm	Z d Z
 Z Z ZZG dd	 d	eZd
d Zeee ddd ddlmZ eee ejd y
ejZW n ek
r   e ZY nX edfddZee_dS )a  Cooperative low-level networking interface.

This module provides socket operations and some related functions.
The API of the functions and classes matches the API of the corresponding
items in the standard :mod:`socket` module exactly, but the synchronous functions
in this module only block the current greenlet and let the others run.

For convenience, exceptions (like :class:`error <socket.error>` and :class:`timeout <socket.timeout>`)
as well as the constants from the :mod:`socket` module are imported into this module.
    )PY3)	exc_clear)copy_globals)_socket3)_socket2 c               @   s   e Zd ZdZdS )errorN)__name__
__module____qualname__errnor   r   r   ,lib/python3.7/site-packages/gevent/socket.pyr      s   r   c              G   s
   t  d S )N)NotImplementedError)argsr   r   r   getfqdn#   s    r   )__implements____dns____all____extensions____imports__
__socket__F)Zdunder_names_to_keepZcleanup_globs)_socketcommon)Z
only_namesNc          	   C   s   | \}}t t||dt}|s&tdx|D ]}|\}}}	}
}d}y:t|||	}|tk	rb|| |rp|| || W nd tk
r   |dk	r|	  d}||d kr t
  Y q, tk
r   |dk	r|	  d} Y q,X z|S d}X q,W dS )a  
    create_connection(address, timeout=None, source_address=None) -> socket

    Connect to *address* and return the :class:`gevent.socket.socket`
    object.

    Convenience function. Connect to *address* (a 2-tuple ``(host,
    port)``) and return the socket object. Passing the optional
    *timeout* parameter will set the timeout on the socket instance
    before attempting to connect. If no *timeout* is supplied, the
    global default timeout setting returned by
    :func:`getdefaulttimeout` is used. If *source_address* is set it
    must be a tuple of (host, port) for the socket to bind as a source
    address before making the connection. A host of '' or port 0 tells
    the OS to use the default.
    r   z!getaddrinfo returns an empty listN)listZgetaddrinfoZSOCK_STREAMr   Zsocket_GLOBAL_DEFAULT_TIMEOUTZ
settimeoutZbindZconnectcloser   BaseException)ZaddressZtimeoutZsource_addressZhostZportZaddrsZresZafZsocktypeproto_ZsaZsockr   r   r   create_connection>   s:    



r   )__doc__Zgevent._compatr   r   Zgevent._utilr   Zgeventr   Z_sourcer   r   r   r   r   r   	Exceptionr   r   globalsr   r   r   AttributeErrorobjectr   r   r   r   r   <module>   s*   


C