def resolve_real_bind_addr(socket_):
        """Retrieve actual bind addr from bound socket."""
        # FIXME: keep requested bind_addr separate real bound_addr (port
        # is different in case of ephemeral port 0)
        bind_addr = socket_.getsockname()
        if socket_.family in (
            # Windows doesn't have socket.AF_UNIX, so not using it in check
            socket.AF_INET,
            socket.AF_INET6,
        ):
            """UNIX domain sockets are strings or bytes.

            In case of bytes with a leading null-byte it's an abstract socket.
            """
            return bind_addr[:2]
        return bind_addr
Retrieve actual bind addr from bound socket.