static int vnc_display_connect(VncDisplay *vd,

                               SocketAddressLegacy **saddr,

                               size_t nsaddr,

                               SocketAddressLegacy **wsaddr,

                               size_t nwsaddr,

                               Error **errp)

{

    /* connect to viewer */

    QIOChannelSocket *sioc = NULL;

    if (nwsaddr != 0) {

        error_setg(errp, "Cannot use websockets in reverse mode");

        return -1;

    }

    if (nsaddr != 1) {

        error_setg(errp, "Expected a single address in reverse mode");

        return -1;

    }

    /* TODO SOCKET_ADDRESS_LEGACY_KIND_FD when fd has AF_UNIX */

    vd->is_unix = saddr[0]->type == SOCKET_ADDRESS_LEGACY_KIND_UNIX;

    sioc = qio_channel_socket_new();

    qio_channel_set_name(QIO_CHANNEL(sioc), "vnc-reverse");

    if (qio_channel_socket_connect_sync(sioc, saddr[0], errp) < 0) {

        return -1;

    }

    vnc_connect(vd, sioc, false, false);

    object_unref(OBJECT(sioc));

    return 0;

}

static int vnc_display_connect(VncDisplay *vd,

                               SocketAddressLegacy **saddr,

                               size_t nsaddr,

                               SocketAddressLegacy **wsaddr,

                               size_t nwsaddr,

                               Error **errp)

{

    

    QIOChannelSocket *sioc = NULL;

    if (nwsaddr != 0) {

        error_setg(errp, "Cannot use websockets in reverse mode");

        return -1;

    }

    if (nsaddr != 1) {

        error_setg(errp, "Expected a single address in reverse mode");

        return -1;

    }

    

    vd->is_unix = saddr[0]->type == SOCKET_ADDRESS_LEGACY_KIND_UNIX;

    sioc = qio_channel_socket_new();

    qio_channel_set_name(QIO_CHANNEL(sioc), "vnc-reverse");

    if (qio_channel_socket_connect_sync(sioc, saddr[0], errp) < 0) {

        return -1;

    }

    vnc_connect(vd, sioc, false, false);

    object_unref(OBJECT(sioc));

    return 0;

}

static int FUNC_0(VncDisplay *VAR_0,

                               SocketAddressLegacy **VAR_1,

                               size_t VAR_2,

                               SocketAddressLegacy **VAR_3,

                               size_t VAR_4,

                               Error **VAR_5)

{

    

    QIOChannelSocket *sioc = NULL;

    if (VAR_4 != 0) {

        error_setg(VAR_5, "Cannot use websockets in reverse mode");

        return -1;

    }

    if (VAR_2 != 1) {

        error_setg(VAR_5, "Expected a single address in reverse mode");

        return -1;

    }

    

    VAR_0->is_unix = VAR_1[0]->type == SOCKET_ADDRESS_LEGACY_KIND_UNIX;

    sioc = qio_channel_socket_new();

    qio_channel_set_name(QIO_CHANNEL(sioc), "vnc-reverse");

    if (qio_channel_socket_connect_sync(sioc, VAR_1[0], VAR_5) < 0) {

        return -1;

    }

    vnc_connect(VAR_0, sioc, false, false);

    object_unref(OBJECT(sioc));

    return 0;

}

static int FUNC_0(VncDisplay *VAR_0,
SocketAddressLegacy **VAR_1,
size_t VAR_2,
SocketAddressLegacy **VAR_3,
size_t VAR_4,
Error **VAR_5)
{ QIOChannelSocket *sioc = NULL; if (VAR_4 != 0) { error_setg(VAR_5, "Cannot use websockets in reverse mode"); return -1; } if (VAR_2 != 1) { error_setg(VAR_5, "Expected a single address in reverse mode"); return -1; } VAR_0->is_unix = VAR_1[0]->type == SOCKET_ADDRESS_LEGACY_KIND_UNIX; sioc = qio_channel_socket_new(); qio_channel_set_name(QIO_CHANNEL(sioc), "vnc-reverse"); if (qio_channel_socket_connect_sync(sioc, VAR_1[0], VAR_5) < 0) { return -1; } vnc_connect(VAR_0, sioc, false, false); object_unref(OBJECT(sioc)); return 0; }