static int tcp_chr_add_client(CharDriverState *chr, int fd)

{

    TCPCharDriver *s = chr->opaque;

    if (s->fd != -1)

	return -1;



    qemu_set_nonblock(fd);

    if (s->do_nodelay)

        socket_set_nodelay(fd);

    s->fd = fd;

    s->chan = io_channel_from_socket(fd);

    g_source_remove(s->listen_tag);

    s->listen_tag = 0;

    tcp_chr_connect(chr);



    return 0;

}

static int tcp_chr_add_client(CharDriverState *chr, int fd)

{

    TCPCharDriver *s = chr->opaque;

    if (s->fd != -1)

	return -1;



    qemu_set_nonblock(fd);

    if (s->do_nodelay)

        socket_set_nodelay(fd);

    s->fd = fd;

    s->chan = io_channel_from_socket(fd);

    g_source_remove(s->listen_tag);

    s->listen_tag = 0;

    tcp_chr_connect(chr);



    return 0;

}

static int FUNC_0(CharDriverState *VAR_0, int VAR_1)

{

    TCPCharDriver *s = VAR_0->opaque;

    if (s->VAR_1 != -1)

	return -1;



    qemu_set_nonblock(VAR_1);

    if (s->do_nodelay)

        socket_set_nodelay(VAR_1);

    s->VAR_1 = VAR_1;

    s->chan = io_channel_from_socket(VAR_1);

    g_source_remove(s->listen_tag);

    s->listen_tag = 0;

    tcp_chr_connect(VAR_0);



    return 0;

}

static int FUNC_0(CharDriverState *VAR_0, int VAR_1)
{ TCPCharDriver *s = VAR_0->opaque; if (s->VAR_1 != -1)
return -1; qemu_set_nonblock(VAR_1); if (s->do_nodelay)
socket_set_nodelay(VAR_1); s->VAR_1 = VAR_1; s->chan = io_channel_from_socket(VAR_1); g_source_remove(s->listen_tag); s->listen_tag = 0; tcp_chr_connect(VAR_0); return 0; }