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

                      socklen_t addrlen, int timeout, URLContext *h,

                      int will_try_next)

{

    struct pollfd p = {fd, POLLOUT, 0};

    int ret;

    socklen_t optlen;



    ff_socket_nonblock(fd, 1);



    while ((ret = connect(fd, addr, addrlen))) {

        ret = ff_neterrno();

        switch (ret) {

        case AVERROR(EINTR):

            if (ff_check_interrupt(&h->interrupt_callback))

                return AVERROR_EXIT;

            continue;

        case AVERROR(EINPROGRESS):

        case AVERROR(EAGAIN):

            ret = ff_poll_interrupt(&p, 1, timeout, &h->interrupt_callback);

            if (ret < 0)

                return ret;

            optlen = sizeof(ret);

            if (getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen))

                ret = AVUNERROR(ff_neterrno());

            if (ret != 0) {

                char errbuf[100];

                ret = AVERROR(ret);

                av_strerror(ret, errbuf, sizeof(errbuf));

                if (will_try_next)

                    av_log(h, AV_LOG_WARNING,

                           "Connection to %s failed (%s), trying next address\n",

                           h->filename, errbuf);

                else

                    av_log(h, AV_LOG_ERROR, "Connection to %s failed: %s\n",

                           h->filename, errbuf);

            }

        default:

            return ret;

        }

    }

    return ret;

}

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

                      socklen_t addrlen, int timeout, URLContext *h,

                      int will_try_next)

{

    struct pollfd p = {fd, POLLOUT, 0};

    int ret;

    socklen_t optlen;



    ff_socket_nonblock(fd, 1);



    while ((ret = connect(fd, addr, addrlen))) {

        ret = ff_neterrno();

        switch (ret) {

        case AVERROR(EINTR):

            if (ff_check_interrupt(&h->interrupt_callback))

                return AVERROR_EXIT;

            continue;

        case AVERROR(EINPROGRESS):

        case AVERROR(EAGAIN):

            ret = ff_poll_interrupt(&p, 1, timeout, &h->interrupt_callback);

            if (ret < 0)

                return ret;

            optlen = sizeof(ret);

            if (getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen))

                ret = AVUNERROR(ff_neterrno());

            if (ret != 0) {

                char errbuf[100];

                ret = AVERROR(ret);

                av_strerror(ret, errbuf, sizeof(errbuf));

                if (will_try_next)

                    av_log(h, AV_LOG_WARNING,

                           "Connection to %s failed (%s), trying next address\n",

                           h->filename, errbuf);

                else

                    av_log(h, AV_LOG_ERROR, "Connection to %s failed: %s\n",

                           h->filename, errbuf);

            }

        default:

            return ret;

        }

    }

    return ret;

}

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

                      socklen_t VAR_2, int VAR_3, URLContext *VAR_4,

                      int VAR_5)

{

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

    int VAR_7;

    socklen_t optlen;



    ff_socket_nonblock(VAR_0, 1);



    while ((VAR_7 = connect(VAR_0, VAR_1, VAR_2))) {

        VAR_7 = ff_neterrno();

        switch (VAR_7) {

        case AVERROR(EINTR):

            if (ff_check_interrupt(&VAR_4->interrupt_callback))

                return AVERROR_EXIT;

            continue;

        case AVERROR(EINPROGRESS):

        case AVERROR(EAGAIN):

            VAR_7 = ff_poll_interrupt(&VAR_6, 1, VAR_3, &VAR_4->interrupt_callback);

            if (VAR_7 < 0)

                return VAR_7;

            optlen = sizeof(VAR_7);

            if (getsockopt (VAR_0, SOL_SOCKET, SO_ERROR, &VAR_7, &optlen))

                VAR_7 = AVUNERROR(ff_neterrno());

            if (VAR_7 != 0) {

                char VAR_8[100];

                VAR_7 = AVERROR(VAR_7);

                av_strerror(VAR_7, VAR_8, sizeof(VAR_8));

                if (VAR_5)

                    av_log(VAR_4, AV_LOG_WARNING,

                           "Connection to %s failed (%s), trying next address\n",

                           VAR_4->filename, VAR_8);

                else

                    av_log(VAR_4, AV_LOG_ERROR, "Connection to %s failed: %s\n",

                           VAR_4->filename, VAR_8);

            }

        default:

            return VAR_7;

        }

    }

    return VAR_7;

}

int FUNC_0(int VAR_0, const struct sockaddr *VAR_1,
socklen_t VAR_2, int VAR_3, URLContext *VAR_4,
int VAR_5)
{ struct pollfd VAR_6 = {VAR_0, POLLOUT, 0}; int VAR_7; socklen_t optlen; ff_socket_nonblock(VAR_0, 1); while ((VAR_7 = connect(VAR_0, VAR_1, VAR_2))) { VAR_7 = ff_neterrno(); switch (VAR_7) { case AVERROR(EINTR):
if (ff_check_interrupt(&VAR_4->interrupt_callback))
return AVERROR_EXIT; continue; case AVERROR(EINPROGRESS):
case AVERROR(EAGAIN):
VAR_7 = ff_poll_interrupt(&VAR_6, 1, VAR_3, &VAR_4->interrupt_callback); if (VAR_7 < 0)
return VAR_7; optlen = sizeof(VAR_7); if (getsockopt (VAR_0, SOL_SOCKET, SO_ERROR, &VAR_7, &optlen))
VAR_7 = AVUNERROR(ff_neterrno()); if (VAR_7 != 0) { char VAR_8[100]; VAR_7 = AVERROR(VAR_7); av_strerror(VAR_7, VAR_8, sizeof(VAR_8)); if (VAR_5)
av_log(VAR_4, AV_LOG_WARNING,
"Connection to %s failed (%s), trying next address\n",
VAR_4->filename, VAR_8); else
av_log(VAR_4, AV_LOG_ERROR, "Connection to %s failed: %s\n",
VAR_4->filename, VAR_8); } default:
return VAR_7; } } return VAR_7; }