'Create a C{SOCK_STREAM} connection to localhost using a socket with an
address family of C{family} and assert that the result of
L{iocpsupport.get_accept_addrs} is consistent with the result of
C{socket.getsockname} and C{socket.getpeername}.'

def _acceptAddressTest(self, family, localhost):

    msg(('family    =    %r' % (family,)))
    port = socket(family, SOCK_STREAM)
    self.addCleanup(port.close)
    port.bind(('', 0))
    port.listen(1)
    client = socket(family, SOCK_STREAM)
    self.addCleanup(client.close)
    client.setblocking(False)
    try:
        client.connect((localhost, port.getsockname()[1]))
    except error as e:
        self.assertIn(e.errno, (errno.EINPROGRESS, errno.EWOULDBLOCK))
    server = socket(family, SOCK_STREAM)
    self.addCleanup(server.close)
    buff = array('B', ('\x00' * 256))
    self.assertEqual(0, _iocp.accept(port.fileno(), server.fileno(), buff, None))
    server.setsockopt(SOL_SOCKET, SO_UPDATE_ACCEPT_CONTEXT, pack('P', port.fileno()))
    self.assertEqual((family, client.getpeername()[:2], client.getsockname()[:2]), _iocp.get_accept_addrs(server.fileno(), buff))
