Esempio n. 1
0
 def socketpair(family=None, type=SOCK_STREAM, proto=0):
     if family is None:
         try:
             family = AF_UNIX
         except NameError:
             family = AF_INET
     (a, b) = _socket.socketpair(family, type, proto)
     a = socket(family, type, proto, a.detach())
     b = socket(family, type, proto, b.detach())
     return (a, b)
Esempio n. 2
0
    def test_EAGAIN(self):
        import _socket, posix
        s1, s2 = _socket.socketpair()
        s2.setblocking(False)
        s1.send("hello")

        f2 = posix.fdopen(posix.dup(s2.fileno()), 'rb', 0)
        data = f2.read(12)
        assert data == "hello"

        f2.close()
        s2.close()
        s1.close()
Esempio n. 3
0
    def socketpair(family=None, type=SOCK_STREAM, proto=0):
        """socketpair([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.
        """
        if family is None:
            try:
                family = AF_UNIX
            except NameError:
                family = AF_INET
        a, b = _socket.socketpair(family, type, proto)
        a = socket(family, type, proto, a.detach())
        b = socket(family, type, proto, b.detach())
        return a, b
Esempio n. 4
0
    def socketpair(family=None, type=SOCK_STREAM, proto=0):
        """Create a pair of socket objects

        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.

        rtype: tuple[socket.socket, socket.socket]
        """
        if family is None:
            try:
                family = AF_UNIX
            except NameError:
                family = AF_INET
        a, b = _socket.socketpair(family, type, proto)
        a = socket(family, type, proto, a.detach())
        b = socket(family, type, proto, b.detach())
        return a, b
Esempio n. 5
0
    def socketpair(family=None, type=SOCK_STREAM, proto=0):
        """socketpair([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.

        .. versionchanged:: 1.2
           All Python 3 versions on Windows supply this function (natively
           supplied by Python 3.5 and above).
        """
        if family is None:
            try:
                family = AF_UNIX
            except NameError:
                family = AF_INET
        a, b = _socket.socketpair(family, type, proto)
        a = socket(family, type, proto, a.detach())
        b = socket(family, type, proto, b.detach())
        return a, b
Esempio n. 6
0
def socketpair(*args):
    one, two = _socket.socketpair(*args)
    return socket(_sock=one), socket(_sock=two)
Esempio n. 7
0
def socketpair(*args):
    one, two = _socket.socketpair(*args)
    return socket(_sock=one), socket(_sock=two)