�
��c@sRdZddkZddkTeZy ddkZddkTeZWnej
onXddkZddkZyddk l
Z
Wnej
o
dZ
nXdgZeiei
e��eoeiei
e��neZeoeZddd�Zneii�id�o�hZd ed
<ded<d
ed<ded<ded<ded<ded<ded<ded<ded<ded<ded <d!ed"<d#ed$<d%ed&<eid'�nd(d)�ZdFZeid8joedGZndHZd@efdA��YZdBefdC��YZeZZdDefdE��YZdS(Is�This 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 [*]
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() -- mape 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)
ssl() -- secure socket layer support (only available if configured)
socket.getdefaulttimeout() -- get the default timeout value
socket.setdefaulttimeout() -- set the default timeout value
[*] 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.
i�N(t*(tEBADFi tgetfqdncCs-t|d�o
|i}nt|||�S(Nt_sock(thasattrRt_realssl(tsocktkeyfiletcertfile((s/sys/lib/python/socket.pytsslGs
twinsThe operation was interrupted.i'sA bad file handle was passed.i'sPermission denied.i's!A fault occurred on the network??i's#An invalid operation was attempted.i&'s The socket operation would blocki3's,A blocking operation is already in progress.i4'sThe network address is in use.i@'sThe connection has been reset.iF'sThe network has been shut down.iJ'sThe operation timed out.iL'sConnection refused.iM'sThe name is too long.iO'sThe host is down.iP'sThe host is unreachable.iQ'terrorTabtcCs�|i�}|p
|djo
t�}nyt|�\}}}Wntj
on;X|id|�x&|D]}d|joPqtqtW|}|S(sGet 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.
s0.0.0.0it.(tstriptgethostnamet
gethostbyaddrterrortinsert(tnamethostnametaliasestipaddrs((s/sys/lib/python/socket.pyRbs
tbindtconnectt
connect_extfilenotlistentgetpeernametgetsocknamet
getsockoptt
setsockopttsendalltsetblockingt
settimeoutt
gettimeouttshutdowntriscost
sleeptaskwtrecvtrecvfromt recv_intot
recvfrom_intotsendtsendtot
_closedsocketcBs7eZgZd�ZeZZZZZZ eZ
RS(cGsttd��dS(NsBad file descriptor(RR(targs((s/sys/lib/python/socket.pyt_dummy�s(t__name__t
__module__t __slots__R/R+R'R)R,R(R*t__getattr__(((s/sys/lib/python/socket.pyR-�s t
_socketobjectcBs�eZeiZddgee�Zeeddd�Z
d�Zeiie_d�Zeiie_d�Z
ddd �Zed
�dd�Zed
�dd�Zed�dd�ZdZx&eD]ZeeeeefdUq�W[[RS(Rt__weakref__icCsZ|djot|||�}n||_x'tD]}t||t||��q3WdS(N(tNonet_realsocketRt_delegate_methodstsetattrtgetattr(tselftfamilyttypetprotoRtmethod((s/sys/lib/python/socket.pyt__init__�s
cCs=t�|_|ii}xtD]}t|||�qWdS(N(R-RR/R8R9(R;tdummyR?((s/sys/lib/python/socket.pytclose�s
cCs(|ii�\}}td|�|fS(NR(RtacceptR4(R;Rtaddr((s/sys/lib/python/socket.pyRC�scCstd|i�S(sadup() -> socket object
Return a new socket object connected to the same system resource.R(R4R(R;((s/sys/lib/python/socket.pytdup�stri�cCst|i||�S(s�makefile([mode[, bufsize]]) -> file object
Return a regular file object corresponding to the socket. The mode
and bufsize arguments are as for the built-in open() function.(t_fileobjectR(R;tmodetbufsize((s/sys/lib/python/socket.pytmakefile�scCs
|iiS((RR<(R;((s/sys/lib/python/socket.pyt<lambda>�stdocsthe socket familycCs
|iiS((RR=(R;((s/sys/lib/python/socket.pyRK�ssthe socket typecCs
|iiS((RR>(R;((s/sys/lib/python/socket.pyRK�ssthe socket protocolsVdef %s(self, *args): return self._sock.%s(*args)
%s.__doc__ = _realsocket.%s.__doc__
N(R0R1R7t__doc__tlistR8R2tAF_INETtSOCK_STREAMR6R@RBRCRERJtpropertyR<R=R>t_st_socketmethodst_m(((s/sys/lib/python/socket.pyR4�s" RGc Bs�eZdZdZdZddddddd d
dg Zdd
ed�Zd�Ze edd�Z
d�Zd�Zd�Z
d�Zd�Zd�Zd�Zd
d�Zd
d�Zdd�Zd�Zd�ZRS(s-Faux file object attached to a socket object.i s<socket>RHRIt softspaceRt _rbufsizet _wbufsizet_rbuft_wbuft_closetrbi�cCs�||_||_|djo
|i}n||_t|_|djo
d|_n'|djo|i|_n
||_||_d|_g|_ ||_
dS(NiiR(RRHtdefault_bufsizeRItFalseRURVRWRXRYRZ(R;RRHRIRB((s/sys/lib/python/socket.pyR@�s
cCs
|idjS(N(RR6(R;((s/sys/lib/python/socket.pyt
_getclosed�sRLsTrue if the file is closedcCsHz|io|i�nWd|io|ii�nd|_XdS(N(RtflushRZRBR6(R;((s/sys/lib/python/socket.pyRB�s
cCsy|i�WnnXdS(N(RB(R;((s/sys/lib/python/socket.pyt__del__�scCs=|io/di|i�}g|_|ii|�ndS(NR(RYtjoinRR (R;tbuffer((s/sys/lib/python/socket.pyR_�s
cCs
|ii�S(N(RR(R;((s/sys/lib/python/socket.pyR�scCs�t|�}|pdSn|ii|�|idjp3|idjo
d|jp|i�|ijo|i�ndS(Niis
(tstrRYtappendRWt
_get_wbuf_lenR_(R;tdata((s/sys/lib/python/socket.pytwrite�scCsZ|iitdtt|���|idjp|i�|ijo|i�ndS(Ni( RYtextendtfilterR6tmapRcRWReR_(R;RN((s/sys/lib/python/socket.pyt
writeliness"cCs.d}x!|iD]}|t|�7}qW|S(Ni(RYtlen(R;tbuf_lentx((s/sys/lib/python/socket.pyRes
cCs�|i}|djo�g}|o|i|�nd|_|idjo
|i}n
|i}x7to/|ii|�}|pPn|i|�qfWdi|�Snt|�}||jo|||_|| Sng}|o|i|�nd|_x�to�||}t |i|�}|ii|�}|pPn|i|�t|�}||jo |||_|| |d<Pn||7}q
Wdi|�SdS(NiRii�(
RXRdRVR\tTrueRR'RaRltmax(R;tsizeRftbufferst recv_sizeRmtlefttn((s/sys/lib/python/socket.pytreadsJ
c Cs|i}|djo{|idjoq|djpt�g}|ii}x7|djo)|d�}|pPn|i|�qOWdi|�Sn|id�}|djo#|d7}|||_|| Sng}|o|i|�nd|_x�tox|ii|i�}|pPn|i|�|id�}|djo*|d7}|||_|| |d<PqqWdi|�Sn�|idd|�}|djo#|d7}|||_|| Snt |�}||jo|||_|| Sng}|o|i|�nd|_x�to�|ii|i�}|pPn|i|�||}|idd|�}|djo*|d7}|||_|| |d<Pnt |�}||jo |||_|| |d<Pn||7}q2Wdi|�SdS(NiiRs
i�(
RXRVtAssertionErrorRR'RdRatfindRoRl( R;RqRfRrR'tnlRmRtRu((s/sys/lib/python/socket.pytreadlineAs�
icCsmd}g}xZtoR|i�}|pPn|i|�|t|�7}|o||joPqqW|S(Ni(RoRzRdRl(R;tsizehintttotalRNtline((s/sys/lib/python/socket.pyt readlines�s
cCs|S(N((R;((s/sys/lib/python/socket.pyt__iter__�scCs!|i�}|p
t�n|S(N(Rzt
StopIteration(R;R}((s/sys/lib/python/socket.pytnext�s
(R0R1RMR\RR2R]R@R^RQtclosedRBR`R_RRgRkReRvRzR~RR�(((s/sys/lib/python/socket.pyRG�s*
+G (RsconnectRsfilenoRRRRRssendallR!R"R#R$(R&(srecvsrecvfroms recv_intos
recvfrom_intossendssendto( RMt_socketR]t _have_sslt_sslRotImportErrortostsysterrnoRt__all__Rht_get_exports_listtsocketR7R RR6tplatformtlowert
startswithRRdRRSR8tobjectR-R4t
SocketTypeRG(((s/sys/lib/python/socket.pys<module>+sj
0
|