def socket_pair():
    '\n    Establish and return a pair of network sockets connected to each other.\n    '
    port = socket_any_family()
    port.bind(('', 0))
    port.listen(1)
    client = socket(port.family)
    client.setblocking(False)
    client.connect_ex((loopback_address(port), port.getsockname()[1]))
    client.setblocking(True)
    server = port.accept()[0]
    server.send(b'x')
    assert (client.recv(1024) == b'x')
    client.send(b'y')
    assert (server.recv(1024) == b'y')
    server.setblocking(False)
    client.setblocking(False)
    return (server, client)
Establish and return a pair of network sockets connected to each other.
def socket_pair():
    '\n    \n    '
    port = socket_any_family()
    port.bind((, 0))
    port.listen(1)
    client = socket(port.family)
    client.setblocking(False)
    client.connect_ex((loopback_address(port), port.getsockname()[1]))
    client.setblocking(True)
    server = port.accept()[0]
    server.send(b'x')
    assert (client.recv(1024) == b'x')
    client.send(b'y')
    assert (server.recv(1024) == b'y')
    server.setblocking(False)
    client.setblocking(False)
    return (server, client)