int ff_listen_bind(int fd, const struct sockaddr *addr,

                   socklen_t addrlen, int timeout)

{

    int ret;

    int reuse = 1;

    struct pollfd lp = { fd, POLLIN, 0 };

    setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse));

    ret = bind(fd, addr, addrlen);

    if (ret)

        return ff_neterrno();



    ret = listen(fd, 1);

    if (ret)

        return ff_neterrno();



    ret = poll(&lp, 1, timeout >= 0 ? timeout : -1);

    if (ret <= 0)

        return AVERROR(ETIMEDOUT);



    ret = accept(fd, NULL, NULL);

    if (ret < 0)

        return ff_neterrno();



    closesocket(fd);



    ff_socket_nonblock(ret, 1);

    return ret;

}

int ff_listen_bind(int fd, const struct sockaddr *addr,

                   socklen_t addrlen, int timeout)

{

    int ret;

    int reuse = 1;

    struct pollfd lp = { fd, POLLIN, 0 };

    setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse));

    ret = bind(fd, addr, addrlen);

    if (ret)

        return ff_neterrno();



    ret = listen(fd, 1);

    if (ret)

        return ff_neterrno();



    ret = poll(&lp, 1, timeout >= 0 ? timeout : -1);

    if (ret <= 0)

        return AVERROR(ETIMEDOUT);



    ret = accept(fd, NULL, NULL);

    if (ret < 0)

        return ff_neterrno();



    closesocket(fd);



    ff_socket_nonblock(ret, 1);

    return ret;

}

int FUNC_0(int VAR_0, const struct sockaddr *VAR_1,

                   socklen_t VAR_2, int VAR_3)

{

    int VAR_4;

    int VAR_5 = 1;

    struct pollfd VAR_6 = { VAR_0, POLLIN, 0 };

    setsockopt(VAR_0, SOL_SOCKET, SO_REUSEADDR, &VAR_5, sizeof(VAR_5));

    VAR_4 = bind(VAR_0, VAR_1, VAR_2);

    if (VAR_4)

        return ff_neterrno();



    VAR_4 = listen(VAR_0, 1);

    if (VAR_4)

        return ff_neterrno();



    VAR_4 = poll(&VAR_6, 1, VAR_3 >= 0 ? VAR_3 : -1);

    if (VAR_4 <= 0)

        return AVERROR(ETIMEDOUT);



    VAR_4 = accept(VAR_0, NULL, NULL);

    if (VAR_4 < 0)

        return ff_neterrno();



    closesocket(VAR_0);



    ff_socket_nonblock(VAR_4, 1);

    return VAR_4;

}

int FUNC_0(int VAR_0, const struct sockaddr *VAR_1,
socklen_t VAR_2, int VAR_3)
{ int VAR_4; int VAR_5 = 1; struct pollfd VAR_6 = { VAR_0, POLLIN, 0 }; setsockopt(VAR_0, SOL_SOCKET, SO_REUSEADDR, &VAR_5, sizeof(VAR_5)); VAR_4 = bind(VAR_0, VAR_1, VAR_2); if (VAR_4)
return ff_neterrno(); VAR_4 = listen(VAR_0, 1); if (VAR_4)
return ff_neterrno(); VAR_4 = poll(&VAR_6, 1, VAR_3 >= 0 ? VAR_3 : -1); if (VAR_4 <= 0)
return AVERROR(ETIMEDOUT); VAR_4 = accept(VAR_0, NULL, NULL); if (VAR_4 < 0)
return ff_neterrno(); closesocket(VAR_0); ff_socket_nonblock(VAR_4, 1); return VAR_4; }