AlkantarClanX12

Your IP : 18.118.144.199


Current Path : /opt/alt/python33/lib64/python3.3/__pycache__/
Upload File :
Current File : //opt/alt/python33/lib64/python3.3/__pycache__/socket.cpython-33.pyc

�
��fA:c
@sPdZddlZddlTddlZddlZddlZyddlZWnek
rjdZYnXeedd�Z	eedd�Z
eedd�Zd	d
gZej
eje��eZejj�jd�r�iZded
<ded<ded<ded<ded<ded<ded<ded<ded<ded<d ed!<d"ed#<d$ed%<d&ed'<d(ed)<ejd*�nGd+d,�d,ej�Zdd-d.�Zeejd/�r�d0d1�Zneed2�r�dedd3d2�Zne
ehZGd4d5�d5ej�Zd6d7d	�Ze�Z e dd8d
�Z!dS(9uThis module provides socket operations and some related functions.
On Unix, it supports IP (Internet Protocol) and Unix domain sockets.
On other systems, it only supports IP. Functions specific for a
socket are available as methods of the socket object.

Functions:

socket() -- create a new socket object
socketpair() -- create a pair of new socket objects [*]
fromfd() -- create a socket object from an open file descriptor [*]
fromshare() -- create a socket object from data received from socket.share() [*]
gethostname() -- return the current hostname
gethostbyname() -- map a hostname to its IP number
gethostbyaddr() -- map an IP number or hostname to DNS info
getservbyname() -- map a service name and a protocol name to a port number
getprotobyname() -- map a protocol name (e.g. 'tcp') to a number
ntohs(), ntohl() -- convert 16, 32 bit int from network to host byte order
htons(), htonl() -- convert 16, 32 bit int from host to network byte order
inet_aton() -- convert IP addr string (123.45.67.89) to 32-bit packed format
inet_ntoa() -- convert 32-bit packed format IP to string (123.45.67.89)
socket.getdefaulttimeout() -- get the default timeout value
socket.setdefaulttimeout() -- set the default timeout value
create_connection() -- connects to an address, with an optional timeout and
                       optional source address.

 [*] not available on all platforms!

Special objects:

SocketType -- type object for socket objects
error -- exception raised for I/O errors
has_ipv6 -- boolean value indicating if IPv6 is supported

Integer constants:

AF_INET, AF_UNIX -- socket domains (first argument to socket() call)
SOCK_STREAM, SOCK_DGRAM, SOCK_RAW -- socket types (second argument)

Many other constants may be defined; these may be used in calls to
the setsockopt() and getsockopt() methods.
iN(u*uEBADFi	uEAGAINiuEWOULDBLOCKugetfqdnucreate_connectionuwinuThe operation was interrupted.i'uA bad file handle was passed.i'uPermission denied.i'u!A fault occurred on the network??i'u#An invalid operation was attempted.i&'u The socket operation would blocki3'u,A blocking operation is already in progress.i4'uThe network address is in use.i@'uThe connection has been reset.iF'uThe network has been shut down.iJ'uThe operation timed out.iL'uConnection refused.iM'uThe name is too long.iO'uThe host is down.iP'uThe host is unreachable.iQ'uerrorTabc
s�|EeZdZdZdddgZeedd"dd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�Zdd"dd"dd"dd"dd�Zdd�Zejdd�Zdd�Z�fd d!�Z�S(#usocketu:A subclass of _socket.socket adding the makefile() method.u__weakref__u_io_refsu_closedicCs2tjj|||||�d|_d|_dS(NiF(u_socketusocketu__init__u_io_refsuFalseu_closed(uselfufamilyutypeuprotoufileno((u+/opt/alt/python33/lib64/python3.3/socket.pyu__init__]s	usocket.__init__cCs|S(N((uself((u+/opt/alt/python33/lib64/python3.3/socket.pyu	__enter__bsusocket.__enter__cGs|js|j�ndS(N(u_closeduclose(uselfuargs((u+/opt/alt/python33/lib64/python3.3/socket.pyu__exit__es	usocket.__exit__c	Csltjj|�}|jd�rhd|jj|jjt|dd�rNdpQd|dd�f}n|S(	u.Wrap __repr__() to reveal the real class name.u<socket objectu
<%s.%s%s%su_closedu
 [closed] uiNF(	u_socketusocketu__repr__u
startswithu	__class__u
__module__u__name__ugetattruFalse(uselfus((u+/opt/alt/python33/lib64/python3.3/socket.pyu__repr__is	usocket.__repr__cCstd��dS(NuCannot serialize socket object(u	TypeError(uself((u+/opt/alt/python33/lib64/python3.3/socket.pyu__getstate__ssusocket.__getstate__cCsMt|j��}|j|j|j|jd|�}|j|j��|S(ujdup() -> socket object

        Return a new socket object connected to the same system resource.
        ufileno(udupufilenou	__class__ufamilyutypeuprotou
settimeoutu
gettimeout(uselfufdusock((u+/opt/alt/python33/lib64/python3.3/socket.pyudupvs$u
socket.dupcCsh|j�\}}t|j|j|jd|�}t�dkr^|j�r^|jd�n||fS(u�accept() -> (socket object, address info)

        Wait for an incoming connection.  Return a new socket
        representing the connection, and the address of the client.
        For IP sockets, the address info is a pair (hostaddr, port).
        ufilenoNT(
u_acceptusocketufamilyutypeuprotougetdefaulttimeoutuNoneu
gettimeoutusetblockinguTrue(uselfufduaddrusock((u+/opt/alt/python33/lib64/python3.3/socket.pyuaccept�s
!u
socket.acceptuencodinguerrorsunewlineurcCs�x)|D]!}|d	krtd��qqWd|k}d|kpH|}|s]|s]t�d|k}	d}
|r�|
d7}
n|r�|
d7}
nt||
�}|jd7_|d
kr�d}n|dkr�tj}n|dkr|	std��n|S|r)|r)tj|||�}n9|rDtj||�}n|sPt�tj	||�}|	rl|Stj
||||�}
||
_|
S(u
makefile(...) -> an I/O stream connected to the socket

        The arguments are as for io.open() after the filename,
        except the only mode characters supported are 'r', 'w' and 'b'.
        The semantics are similar too.  (XXX refactor to share code?)
        uruwubu&invalid mode %r (only r, w, b allowed)uiiu!unbuffered streams must be binary>uwurubNi����(u
ValueErroruAssertionErroruSocketIOu_io_refsuNoneuiouDEFAULT_BUFFER_SIZEuBufferedRWPairuBufferedReaderuBufferedWriteru
TextIOWrapperumode(uselfumodeu	bufferinguencodinguerrorsunewlineucuwritingureadingubinaryurawmodeurawubufferutext((u+/opt/alt/python33/lib64/python3.3/socket.pyumakefile�sB


		usocket.makefilecCs;|jdkr!|jd8_n|jr7|j�ndS(Nii(u_io_refsu_closeduclose(uself((u+/opt/alt/python33/lib64/python3.3/socket.pyu_decref_socketios�s	usocket._decref_socketioscCs|j|�dS(N(uclose(uselfu_ss((u+/opt/alt/python33/lib64/python3.3/socket.pyu_real_close�susocket._real_closecCs)d|_|jdkr%|j�ndS(NiT(uTrueu_closedu_io_refsu_real_close(uself((u+/opt/alt/python33/lib64/python3.3/socket.pyuclose�s	usocket.closecsd|_t�j�S(udetach() -> file descriptor

        Close the socket object without closing the underlying file descriptor.
        The object cannot be used after this call, but the file descriptor
        can be reused for other purposes.  The file descriptor is returned.
        T(uTrueu_closedusuperudetach(uself(u	__class__(u+/opt/alt/python33/lib64/python3.3/socket.pyudetach�s	u
socket.detachN(u__name__u
__module__u__qualname__u__doc__u	__slots__uAF_INETuSOCK_STREAMuNoneu__init__u	__enter__u__exit__u__repr__u__getstate__udupuacceptumakefileu_decref_socketiosu_socketusocketu_real_closeucloseudetach(u
__locals__((u	__class__u+/opt/alt/python33/lib64/python3.3/socket.pyusocketWs

!*usocketcCst|�}t||||�S(u� fromfd(fd, family, type[, proto]) -> socket object

    Create a socket object from a duplicate of the given file
    descriptor.  The remaining arguments are the same as for socket().
    (udupusocket(ufdufamilyutypeuprotounfd((u+/opt/alt/python33/lib64/python3.3/socket.pyufromfd�sufromfdusharecCstddd|�S(u� fromshare(info) -> socket object

        Create a socket object from a the bytes object returned by
        socket.share(pid).
        i(usocket(uinfo((u+/opt/alt/python33/lib64/python3.3/socket.pyu	fromshare�su	fromshareu
socketpairc
Cs�|dkr4y
t}Wq4tk
r0t}Yq4Xntj|||�\}}t||||j��}t||||j��}||fS(uasocketpair([family[, type[, proto]]]) -> (socket object, socket object)

        Create a pair of socket objects from the sockets returned by the platform
        socketpair() function.
        The arguments are the same as for socket() except the default family is
        AF_UNIX if defined on the platform; otherwise, the default is AF_INET.
        N(uNoneuAF_UNIXu	NameErroruAF_INETu_socketu
socketpairusocketudetach(ufamilyutypeuprotouaub((u+/opt/alt/python33/lib64/python3.3/socket.pyu
socketpair�s

cs�|EeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Z�fdd
�Z	dd�Z
edd��Zedd��Z
dd�Z�S(uSocketIOu�Raw I/O implementation for stream sockets.

    This class supports the makefile() method on sockets.  It provides
    the raw I/O interface on top of a socket object.
    cCs�|d	krtd|��ntjj|�||_d|krQ|d7}n||_d|k|_d|k|_d
|_	dS(Nuruwurwurbuwburwbuinvalid mode: %rub(uruwurwurbuwburwbF(
u
ValueErroruiou	RawIOBaseu__init__u_socku_modeu_readingu_writinguFalseu_timeout_occurred(uselfusockumode((u+/opt/alt/python33/lib64/python3.3/socket.pyu__init__s	
	uSocketIO.__init__cCs�|j�|j�|jr,td��nx�y|jj|�SWq/tk
rcd|_�Yq/tk
rww/Yq/t	k
r�}z|j
dtkr�dS�WYdd}~Xq/Xq/dS(u3Read up to len(b) bytes into the writable buffer *b* and return
        the number of bytes read.  If the socket is non-blocking and no bytes
        are available, None is returned.

        If *b* is non-empty, a 0 return value indicates that the connection
        was shutdown at the other end.
        u!cannot read from timed out objectiNT(
u_checkClosedu_checkReadableu_timeout_occurreduIOErroru_socku	recv_intoutimeoutuTrueuInterruptedErroruerroruargsu_blocking_errnosuNone(uselfubue((u+/opt/alt/python33/lib64/python3.3/socket.pyureadintos 

	
	
uSocketIO.readintocCsn|j�|j�y|jj|�SWn?tk
ri}z|jdtkrTdS�WYdd}~XnXdS(uWrite the given bytes or bytearray object *b* to the socket
        and return the number of bytes written.  This can be less than
        len(b) if not all data could be written.  If the socket is
        non-blocking and no bytes could be written None is returned.
        iN(u_checkClosedu_checkWritableu_sockusenduerroruargsu_blocking_errnosuNone(uselfubue((u+/opt/alt/python33/lib64/python3.3/socket.pyuwrite4s

uSocketIO.writecCs|jrtd��n|jS(u2True if the SocketIO is open for reading.
        uI/O operation on closed socket.(uclosedu
ValueErroru_reading(uself((u+/opt/alt/python33/lib64/python3.3/socket.pyureadableDs	uSocketIO.readablecCs|jrtd��n|jS(u2True if the SocketIO is open for writing.
        uI/O operation on closed socket.(uclosedu
ValueErroru_writing(uself((u+/opt/alt/python33/lib64/python3.3/socket.pyuwritableKs	uSocketIO.writablecs%|jrtd��nt�j�S(u2True if the SocketIO is open for seeking.
        uI/O operation on closed socket.(uclosedu
ValueErrorusuperuseekable(uself(u	__class__(u+/opt/alt/python33/lib64/python3.3/socket.pyuseekableRs	uSocketIO.seekablecCs|j�|jj�S(u=Return the file descriptor of the underlying socket.
        (u_checkClosedu_sockufileno(uself((u+/opt/alt/python33/lib64/python3.3/socket.pyufilenoYs
uSocketIO.filenocCs|js|j�SdSdS(Nii����(uclosedufileno(uself((u+/opt/alt/python33/lib64/python3.3/socket.pyuname_s	
u
SocketIO.namecCs|jS(N(u_mode(uself((u+/opt/alt/python33/lib64/python3.3/socket.pyumodefsu
SocketIO.modecCs7|jr
dStjj|�|jj�d|_dS(u�Close the SocketIO object.  This doesn't close the underlying
        socket, except if all references to it have disappeared.
        N(ucloseduiou	RawIOBaseucloseu_socku_decref_socketiosuNone(uself((u+/opt/alt/python33/lib64/python3.3/socket.pyuclosejs
	
uSocketIO.close(u__name__u
__module__u__qualname__u__doc__u__init__ureadintouwriteureadableuwritableuseekableufilenoupropertyunameumodeuclose(u
__locals__((u	__class__u+/opt/alt/python33/lib64/python3.3/socket.pyuSocketIO�suSocketIOucCs�|j�}|s|dkr+t�}nyt|�\}}}Wntk
rXYn8X|jd|�x$|D]}d|krpPqpqpW|}|S(uGet fully qualified domain name from name.

    An empty argument is interpreted as meaning the local host.

    First the hostname returned by gethostbyaddr() is checked, then
    possibly existing aliases. In case no FQDN is available, hostname
    from gethostname() is returned.
    u0.0.0.0iu.(ustripugethostnameu
gethostbyaddruerroruinsert(unameuhostnameualiasesuipaddrs((u+/opt/alt/python33/lib64/python3.3/socket.pyugetfqdnus	

cCs|\}}d}x�t||dt�D]�}|\}}}	}
}d}yYt|||	�}|tk	rz|j|�n|r�|j|�n|j|�|SWq(tk
r�}
z$|
}|dk	r�|j	�nWYdd}
~
Xq(Xq(W|dk	r|�ntd��dS(udConnect to *address* and return the 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.
    An host of '' or port 0 tells the OS to use the default.
    iNu!getaddrinfo returns an empty list(
uNoneugetaddrinfouSOCK_STREAMusocketu_GLOBAL_DEFAULT_TIMEOUTu
settimeoutubinduconnectuerroruclose(uaddressutimeoutusource_addressuhostuportuerruresuafusocktypeuprotou	canonnameusausocku_((u+/opt/alt/python33/lib64/python3.3/socket.pyucreate_connection�s(
$	("u__doc__u_socketuosusysuiouerrnouImportErroruNoneugetattruEBADFuEAGAINuEWOULDBLOCKu__all__uextendu_get_exports_listusocketu_realsocketuplatformuloweru
startswithuerrorTabuappendufromfduhasattru	fromshareuSOCK_STREAMu
socketpairu_blocking_errnosu	RawIOBaseuSocketIOugetfqdnuobjectu_GLOBAL_DEFAULT_TIMEOUTucreate_connection(((u+/opt/alt/python33/lib64/python3.3/socket.pyu<module>-sV
$















~	w