B ^†€ÝïdOã@slddlZddlTddlZddlZddlZddlZddlmZmZy ddlZWne k rddZYnXe eddƒZ e eddƒZ e eddƒZ d d d d d gZe e e¡¡e d edd„¡e d edd„¡e dedd„¡e dedd„¡dZdZdd„ZeZej ¡ d¡rœiZded<ded<ded<d ed!<d"ed#<d$ed%<d&ed'<d(ed)<d*ed+<d,ed-<d.ed/<d0ed1<d2ed3<d4ed5<d6ed7<e d8¡Gd9d:„d:eƒZGd;d<„dƒrèd?d@„Z!e d@¡e edAƒrde"dfdBdA„Z#ne$e"dfdCdA„Z#e dA¡dDe#_%e e hZ&GdEdF„dFej'ƒZ(dMdHd „Z)e*ƒZ+e+dfdId „Z,dNdJdK„Z-dS)OéN)Ú*)ÚIntEnumÚIntFlagÚEBADFé ÚEAGAINé Ú EWOULDBLOCKÚfromfdÚgetfqdnÚcreate_connectionÚ AddressFamilyÚ SocketKindcCs| ¡o| d¡S)NZAF_)ÚisupperÚ startswith)ÚC©rú)/opt/alt/python37/lib/python3.7/socket.pyÚLórcCs| ¡o| d¡S)NZSOCK_)rr)rrrrrQrZMsgFlagcCs| ¡o| d¡S)NZMSG_)rr)rrrrrVrZ AddressInfocCs| ¡o| d¡S)NZAI_)rr)rrrrr[rz 127.0.0.1z::1cCs"y||ƒStk r|SXdS)N)Ú ValueError)ÚvalueZ enum_klassrrrÚ_intenum_converterasrÚwinzThe operation was interrupted.i'zA bad file handle was passed.i'zPermission denied.i'z!A fault occurred on the network??i'z#An invalid operation was attempted.i&'z The socket operation would blocki3'z,A blocking operation is already in progress.i4'zThe network address is in use.i@'zThe connection has been reset.iF'zThe network has been shut down.iJ'zThe operation timed out.iL'zConnection refused.iM'zThe name is too long.iO'zThe host is down.iP'zThe host is unreachable.iQ'ÚerrorTabc@s eZdZdS)Ú_GiveupOnSendfileN)Ú__name__Ú __module__Ú __qualname__rrrrr‚srcs(eZdZdddgZd8dd„Zdd „Zd d „Zd d „Zdd„Zdd„Z dd„Z d9ddddœdd„Z e e dƒrvd:dd„Zn d;dd„ZdÚsocketÚ __weakref__Ú_io_refsÚ_closedéÿÿÿÿNcCsP|dkr,|dkrt}|dkr t}|dkr,d}tj |||||¡d|_d|_dS)Nr#rF)ÚAF_INETÚ SOCK_STREAMÚ_socketrÚ__init__r!r")ÚselfÚfamilyÚtypeÚprotoÚfilenorrrr'‹szsocket.__init__cCs|S)Nr)r(rrrÚ __enter__›szsocket.__enter__cGs|js| ¡dS)N)r"Úclose)r(ÚargsrrrÚ__exit__žszsocket.__exit__cCs¸t|ddƒ}d|jj|jj|r"dnd| ¡|j|j|jf}|s¬y | ¡}|r^|dt |ƒ7}Wnt k rtYnXy |  ¡}|r”|dt |ƒ7}Wnt k rªYnX|d7}|S) Nr"Fz,<%s.%s%s fd=%i, family=%s, type=%s, proto=%iz [closed]Úz , laddr=%sz , raddr=%sú>) ÚgetattrÚ __class__rrr,r)r*r+Ú getsocknameÚstrÚerrorZ getpeername)r(ÚclosedÚsZladdrZraddrrrrÚ__repr__¢s0   zsocket.__repr__cCs tdƒ‚dS)NzCannot serialize socket object)Ú TypeError)r(rrrÚ __getstate__¿szsocket.__getstate__cCs6t| ¡ƒ}|j|j|j|j|d}| | ¡¡|S)N)r,)Údupr,r4r)r*r+Ú settimeoutÚ gettimeout)r(ÚfdÚsockrrrr=Âs z socket.dupcCsF| ¡\}}t|j|j|j|d}tƒdkr>| ¡r>| d¡||fS)N)r,T)Z_acceptrr)r*r+Zgetdefaulttimeoutr?Ú setblocking)r(r@ÚaddrrArrrÚacceptÍs   z socket.acceptÚr)ÚencodingÚerrorsÚnewlinec Csüt|ƒdddhks td|fƒ‚d|k}d|kp4| }d|k}d} |rN| d7} |rZ| d7} t|| ƒ} |jd7_|dkr~d}|dkrŒtj}|dkr¤|s td ƒ‚| S|r¼|r¼t | | |¡} n|rÎt | |¡} n t | |¡} |râ| St  | |||¡} || _ | S) NrEÚwÚbz&invalid mode %r (only r, w, b allowed)r1ér#rz!unbuffered streams must be binary) ÚsetrÚSocketIOr!ÚioÚDEFAULT_BUFFER_SIZEÚBufferedRWPairÚBufferedReaderÚBufferedWriterÚ TextIOWrapperÚmode) r(rTÚ bufferingrFrGrHZwritingZreadingZbinaryZrawmodeÚrawÚbufferÚtextrrrÚmakefileÝs<  zsocket.makefileÚsendfilerc Csê| |||¡| ¡}y | ¡}Wn0ttjfk rR}z t|ƒ‚Wdd}~XYnXyt |¡j}Wn*t k rŽ}z t|ƒ‚Wdd}~XYnX|s˜dS|s |n|}|  ¡} | dkr¼t dƒ‚t t dƒrÐt  ¡} nt  ¡} |  |t j¡d} | j} tj} zÌxÆ| r| | ƒst d¡‚|r.|| }|dkr.Py| ||||ƒ}Wn^tk rd| s^| ƒwúYqút k rž}z| dkrˆt|ƒ‚|d‚Wdd}~XYqúX|dkr¬P||7}| |7} qúW| S| dkrät |dƒrä| |¡XdS)Nrz&non-blocking sockets are not supportedÚ PollSelectorz timed outÚseek)Ú_check_sendfile_paramsr,ÚAttributeErrorrNÚUnsupportedOperationrÚosÚfstatÚst_sizeÚOSErrorr?rÚhasattrÚ selectorsr[ZSelectSelectorÚregisterZ EVENT_WRITEZselectrZr&ÚtimeoutÚBlockingIOErrorr\)r(ÚfileÚoffsetÚcountZsocknor,ÚerrZfsizeÚ blocksizergZselectorÚ total_sentZselector_selectZ os_sendfileÚsentrrrÚ_sendfile_use_sendfile s`         zsocket._sendfile_use_sendfilecCs tdƒ‚dS)Nz,os.sendfile() not available on this platform)r)r(rirjrkrrrrpJsc Cs| |||¡| ¡dkr"tdƒ‚|r0| |¡|r>t|dƒnd}d}|j}|j}z†x€|rrt|||ƒ}|dkrrPt||ƒƒ}|s„PxLy ||ƒ} Wntk r¨w†Yq†X|| 7}| t |ƒkrÌ|| d…}q†Pq†WqVW|S|dkrút |dƒrú| ||¡XdS)Nrz&non-blocking sockets are not supportedi r\) r]r?rr\ÚminÚreadÚsendÚ memoryviewrhÚlenrd) r(rirjrkrmrnZ file_readZ sock_sendÚdatarorrrÚ_sendfile_use_sendNs<      zsocket._sendfile_use_sendcCsddt|ddƒkrtdƒ‚|jt@s*tdƒ‚|dk r`t|tƒsJtd |¡ƒ‚|dkr`td |¡ƒ‚dS)NrJrTz$file should be opened in binary modez+only SOCK_STREAM type sockets are supportedz+count must be a positive integer (got {!r})r)r3rr*r%Ú isinstanceÚintr;Úformat)r(rirjrkrrrr]rs   zsocket._check_sendfile_paramscCs2y| |||¡Stk r,| |||¡SXdS)N)rprrw)r(rirjrkrrrrZszsocket.sendfilecCs*|jdkr|jd8_|jr&| ¡dS)NrrK)r!r"r.)r(rrrÚ_decref_socketios–s zsocket._decref_socketioscCs| |¡dS)N)r.)r(Z_ssrrrÚ _real_closeœszsocket._real_closecCsd|_|jdkr| ¡dS)NTr)r"r!r|)r(rrrr. s z socket.closecsd|_tƒ ¡S)NT)r"ÚsuperÚdetach)r()r4rrr~¦sz socket.detachcsttƒjtƒS)N)rr}r)r )r()r4rrr)°sz socket.familycsttƒjtƒS)N)rr}r*r)r()r4rrr*¶sz socket.typeÚntcCst | ¡¡S)N)r`Zget_handle_inheritabler,)r(rrrÚget_inheritable½szsocket.get_inheritablecCst | ¡|¡dS)N)r`Zset_handle_inheritabler,)r(Ú inheritablerrrÚset_inheritable¿szsocket.set_inheritablecCst | ¡¡S)N)r`r€r,)r(rrrr€ÂscCst | ¡|¡dS)N)r`r‚r,)r(rrrrr‚Äsz&Get the inheritable flag of the socketz&Set the inheritable flag of the socket)r#r#r#N)rEN)rN)rN)rN)rN) rrrÚ __slots__r'r-r0r:r<r=rDrYrdr`rprwr]rZr{r&rr|r.r~Úpropertyr)r*Únamer€r‚Ú__doc__Ú __classcell__rr)r4rr…s:   )  A  $    rcCst|ƒ}t||||ƒS)N)r=r)r@r)r*r+Znfdrrrr ÉsZsharecCstddd|ƒS)Nr)r)ÚinforrrÚ fromshareÓsr‰Ú socketpaircCsh|dkr*yt}Wntk r(t}YnXt |||¡\}}t|||| ¡ƒ}t|||| ¡ƒ}||fS)N)ZAF_UNIXÚ NameErrorr$r&rŠrr~)r)r*r+ÚarJrrrrŠÞs c Cs|tkrt}n|tkrt}ntdƒ‚|tkr4tdƒ‚|dkrDtdƒ‚t|||ƒ}z¢| |df¡| ¡|  ¡dd…\}}t|||ƒ}yP|  d¡y|  ||f¡Wnt t fk r¾YnX|  d¡| ¡\}} Wn| ¡‚YnXWd| ¡X||fS)Nz?Only AF_INET and AF_INET6 socket address families are supportedz)Only SOCK_STREAM socket type is supportedrzOnly protocol zero is supportedéFT)r$Ú _LOCALHOSTZAF_INET6Ú _LOCALHOST_V6rr%rÚbindZlistenr5rBÚconnectrhÚInterruptedErrorrDr.) r)r*r+ÚhostZlsockrCÚportZcsockZssockÚ_rrrrŠós8      a8socketpair([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. csleZdZdd„Zdd„Zdd„Zdd„Zd d „Z‡fd d „Zd d„Z e dd„ƒZ e dd„ƒZ dd„Z ‡ZS)rMcCsZ|dkrtd|ƒ‚tj |¡||_d|kr6|d7}||_d|k|_d|k|_d|_dS)N)rErIÚrwÚrbÚwbZrwbzinvalid mode: %rrJrErIF) rrNÚ RawIOBaser'Ú_sockÚ_modeÚ_readingÚ_writingÚ_timeout_occurred)r(rArTrrrr'3s    zSocketIO.__init__c Cs†| ¡| ¡|jrtdƒ‚xby |j |¡Stk rHd|_‚Yq tk r|}z|jdt krjdS‚Wdd}~XYq Xq WdS)Nz!cannot read from timed out objectTr) Ú _checkClosedÚ_checkReadableržrcršZ recv_intorgr7r/Ú_blocking_errnos)r(rJÚerrrÚreadinto?s zSocketIO.readintoc CsX| ¡| ¡y |j |¡Stk rR}z|jdtkr@dS‚Wdd}~XYnXdS)Nr)rŸÚ_checkWritableršrsr7r/r¡)r(rJr¢rrrÚwriteVs zSocketIO.writecCs|jrtdƒ‚|jS)NzI/O operation on closed socket.)r8rrœ)r(rrrÚreadablefszSocketIO.readablecCs|jrtdƒ‚|jS)NzI/O operation on closed socket.)r8rr)r(rrrÚwritablemszSocketIO.writablecs|jrtdƒ‚tƒ ¡S)NzI/O operation on closed socket.)r8rr}Úseekable)r()r4rrr¨tszSocketIO.seekablecCs| ¡|j ¡S)N)rŸršr,)r(rrrr,{szSocketIO.filenocCs|js| ¡SdSdS)Nr#)r8r,)r(rrrr…sz SocketIO.namecCs|jS)N)r›)r(rrrrTˆsz SocketIO.modecCs*|jr dStj |¡|j ¡d|_dS)N)r8rNr™r.ršr{)r(rrrr.Œs   zSocketIO.close)rrrr'r£r¥r¦r§r¨r,r„r…rTr.r‡rr)r4rrM"s    rMr1cCsn| ¡}|r|dkrtƒ}yt|ƒ\}}}Wntk r@Yn*X| d|¡x|D]}d|krTPqTW|}|S)Nz0.0.0.0rÚ.)ÚstripZ gethostnameZ gethostbyaddrr7Úinsert)r…ZhostnameÚaliasesZipaddrsrrrr —s    c CsÒ|\}}d}xžt||dtƒD]Œ}|\}}} } } d} y>t||| ƒ} |tk rR|  |¡|r`|  |¡|  | ¡d}| Stk r¦} z| }| dk r–|  ¡Wdd} ~ XYqXqW|dk rÆz|‚Wdd}Xntdƒ‚dS)Nrz!getaddrinfo returns an empty list) Ú getaddrinfor%rÚ_GLOBAL_DEFAULT_TIMEOUTr>rr‘r7r.)ZaddressrgZsource_addressr“r”rlÚresÚafÚsocktyper+Ú canonnameÚsarAr•rrrr ³s.    c CsTg}xJt ||||||¡D]2}|\}} }} } | t|tƒt| tƒ|| | f¡qW|S)N)r&r­Úappendrr r) r“r”r)r*r+ÚflagsZaddrlistr¯r°r±r²r³rrrr­ßs r­)r)r1)rrrr).r&r`ÚsysrNreÚenumrrÚerrnoÚ ImportErrorr3rrr Ú__all__ÚextendÚ_get_exports_listÚ_convertrrŽrrrZ _realsocketÚplatformÚlowerrrr´Ú Exceptionrr rdr‰r%rŠr$r†r¡r™rMr Úobjectr®r r­rrrrÚ1sŽ            F   $ u  +