Takes (socket path, 0) and returns (socket_object, (path, 0)).

def bind_domain_socket(address):
    """Takes (socket path, 0) and returns (socket_object, (path, 0))."""
    path, _ = address
    try:
        os.unlink(path)
    except OSError:
        pass

    sock = socket.socket(socket.AF_UNIX)
    sock.bind(path)
    sock.listen(128)
    return sock, (path, 0)