diff options
Diffstat (limited to 'modules/language/python/module/socket.py')
-rw-r--r-- | modules/language/python/module/socket.py | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/modules/language/python/module/socket.py b/modules/language/python/module/socket.py index 31b814a..cb70bc8 100644 --- a/modules/language/python/module/socket.py +++ b/modules/language/python/module/socket.py @@ -47,33 +47,32 @@ Integer constants: Many other constants may be defined; these may be used in calls to the setsockopt() and getsockopt() methods. """ -pk(0,1) + import _socket from _socket import * -pk(0,2) import os, sys, io, selectors from enum import IntEnum, IntFlag -pk(0,3) + try: import errno except ImportError: errno = None -pk(0,4) + EBADF = getattr(errno, 'EBADF', 9) EAGAIN = getattr(errno, 'EAGAIN', 11) EWOULDBLOCK = getattr(errno, 'EWOULDBLOCK', 11) -pk(0,5) + __all__ = ["fromfd", "getfqdn", "create_connection", "AddressFamily", "SocketKind"] __all__.extend(os._get_exports_list(_socket)) -pk(0,6) + # Set up the socket.AF_* socket.SOCK_* constants as members of IntEnums for # nicer string representations. # Note that _socket only knows about the integer values. The public interface # in this module understands the enums and translates them back from integers # where needed (e.g. .family property of a socket object). name__ = '_socket' -pk(1) + IntEnum._convert( 'AddressFamily', name__, @@ -92,7 +91,7 @@ IntFlag._convert( 'AddressInfo', name__, lambda C: C.isupper() and C.startswith('AI_')) -pk(2) + _LOCALHOST = '127.0.0.1' _LOCALHOST_V6 = '::1' @@ -462,7 +461,7 @@ def fromfd(fd, family, type, proto=0): """ nfd = dup(fd) return socket(family, type, proto, nfd) -pk(3) + if hasattr(_socket.socket, "share"): def fromshare(info): """ fromshare(info) -> socket object @@ -472,7 +471,7 @@ if hasattr(_socket.socket, "share"): """ return socket(0, 0, 0, info) __all__.append("fromshare") -pk(4) + if hasattr(_socket, "socketpair"): def socketpair(family=None, type=SOCK_STREAM, proto=0): @@ -533,7 +532,7 @@ else: lsock.close() return (ssock, csock) __all__.append("socketpair") -pk(5) + socketpair.__doc__ = """socketpair([family[, type[, proto]]]) -> (socket object, socket object) Create a pair of socket objects from the sockets returned by the platform socketpair() function. @@ -751,4 +750,4 @@ def getaddrinfo(host, port, family=0, type=0, proto=0, flags=0): _intenum_converter(socktype, SocketKind), proto, canonname, sa)) return addrlist -pk(6) + |