static int http_server(void)
{
    int server_fd, ret, rtsp_server_fd, delay, delay1;
    struct pollfd poll_table[HTTP_MAX_CONNECTIONS + 2], *poll_entry;
    HTTPContext *c, *c_next;
    server_fd = socket_open_listen(&my_http_addr);
    if (server_fd < 0)
        return -1;
    rtsp_server_fd = socket_open_listen(&my_rtsp_addr);
    if (rtsp_server_fd < 0)
        return -1;
    http_log("ffserver started.\n");
    start_children(first_feed);
    first_http_ctx = NULL;
    nb_connections = 0;
    start_multicast();
    for(;;) {
        poll_entry = poll_table;
        poll_entry->fd = server_fd;
        poll_entry->events = POLLIN;
        poll_entry++;
        poll_entry->fd = rtsp_server_fd;
        poll_entry->events = POLLIN;
        poll_entry++;
        c = first_http_ctx;
        delay = 1000;
        while (c != NULL) {
            int fd;
            fd = c->fd;
            switch(c->state) {
            case HTTPSTATE_SEND_HEADER:
            case RTSPSTATE_SEND_REPLY:
            case RTSPSTATE_SEND_PACKET:
                c->poll_entry = poll_entry;
                poll_entry->fd = fd;
                poll_entry->events = POLLOUT;
                poll_entry++;
                break;
            case HTTPSTATE_SEND_DATA_HEADER:
            case HTTPSTATE_SEND_DATA:
            case HTTPSTATE_SEND_DATA_TRAILER:
                if (!c->is_packetized) {
                    c->poll_entry = poll_entry;
                    poll_entry->fd = fd;
                    poll_entry->events = POLLOUT;
                    poll_entry++;
                } else {
                    delay1 = 10;
                    if (delay1 < delay)
                        delay = delay1;
                }
                break;
            case HTTPSTATE_WAIT_REQUEST:
            case HTTPSTATE_RECEIVE_DATA:
            case HTTPSTATE_WAIT_FEED:
            case RTSPSTATE_WAIT_REQUEST:
                c->poll_entry = poll_entry;
                poll_entry->fd = fd;
                poll_entry->events = POLLIN;
                poll_entry++;
                break;
            default:
                c->poll_entry = NULL;
                break;
            }
            c = c->next;
        }
        do {
            ret = poll(poll_table, poll_entry - poll_table, delay);
            if (ret < 0 && ff_neterrno() != FF_NETERROR(EAGAIN) &&
                ff_neterrno() != FF_NETERROR(EINTR))
                return -1;
        } while (ret < 0);
        cur_time = av_gettime() / 1000;
        if (need_to_start_children) {
            need_to_start_children = 0;
            start_children(first_feed);
        }
        for(c = first_http_ctx; c != NULL; c = c_next) {
            c_next = c->next;
            if (handle_connection(c) < 0) {
                log_connection(c);
                close_connection(c);
            }
        }
        poll_entry = poll_table;
        if (poll_entry->revents & POLLIN)
            new_connection(server_fd, 0);
        poll_entry++;
        if (poll_entry->revents & POLLIN)
            new_connection(rtsp_server_fd, 1);
    }
}
['static int http_server(void)\n{\n    int server_fd, ret, rtsp_server_fd, delay, delay1;\n    struct pollfd poll_table[HTTP_MAX_CONNECTIONS + 2], *poll_entry;\n    HTTPContext *c, *c_next;\n    server_fd = socket_open_listen(&my_http_addr);\n    if (server_fd < 0)\n        return -1;\n    rtsp_server_fd = socket_open_listen(&my_rtsp_addr);\n    if (rtsp_server_fd < 0)\n        return -1;\n    http_log("ffserver started.\\n");\n    start_children(first_feed);\n    first_http_ctx = NULL;\n    nb_connections = 0;\n    start_multicast();\n    for(;;) {\n        poll_entry = poll_table;\n        poll_entry->fd = server_fd;\n        poll_entry->events = POLLIN;\n        poll_entry++;\n        poll_entry->fd = rtsp_server_fd;\n        poll_entry->events = POLLIN;\n        poll_entry++;\n        c = first_http_ctx;\n        delay = 1000;\n        while (c != NULL) {\n            int fd;\n            fd = c->fd;\n            switch(c->state) {\n            case HTTPSTATE_SEND_HEADER:\n            case RTSPSTATE_SEND_REPLY:\n            case RTSPSTATE_SEND_PACKET:\n                c->poll_entry = poll_entry;\n                poll_entry->fd = fd;\n                poll_entry->events = POLLOUT;\n                poll_entry++;\n                break;\n            case HTTPSTATE_SEND_DATA_HEADER:\n            case HTTPSTATE_SEND_DATA:\n            case HTTPSTATE_SEND_DATA_TRAILER:\n                if (!c->is_packetized) {\n                    c->poll_entry = poll_entry;\n                    poll_entry->fd = fd;\n                    poll_entry->events = POLLOUT;\n                    poll_entry++;\n                } else {\n                    delay1 = 10;\n                    if (delay1 < delay)\n                        delay = delay1;\n                }\n                break;\n            case HTTPSTATE_WAIT_REQUEST:\n            case HTTPSTATE_RECEIVE_DATA:\n            case HTTPSTATE_WAIT_FEED:\n            case RTSPSTATE_WAIT_REQUEST:\n                c->poll_entry = poll_entry;\n                poll_entry->fd = fd;\n                poll_entry->events = POLLIN;\n                poll_entry++;\n                break;\n            default:\n                c->poll_entry = NULL;\n                break;\n            }\n            c = c->next;\n        }\n        do {\n            ret = poll(poll_table, poll_entry - poll_table, delay);\n            if (ret < 0 && ff_neterrno() != FF_NETERROR(EAGAIN) &&\n                ff_neterrno() != FF_NETERROR(EINTR))\n                return -1;\n        } while (ret < 0);\n        cur_time = av_gettime() / 1000;\n        if (need_to_start_children) {\n            need_to_start_children = 0;\n            start_children(first_feed);\n        }\n        for(c = first_http_ctx; c != NULL; c = c_next) {\n            c_next = c->next;\n            if (handle_connection(c) < 0) {\n                log_connection(c);\n                close_connection(c);\n            }\n        }\n        poll_entry = poll_table;\n        if (poll_entry->revents & POLLIN)\n            new_connection(server_fd, 0);\n        poll_entry++;\n        if (poll_entry->revents & POLLIN)\n            new_connection(rtsp_server_fd, 1);\n    }\n}', 'static int socket_open_listen(struct sockaddr_in *my_addr)\n{\n    int server_fd, tmp;\n    server_fd = socket(AF_INET,SOCK_STREAM,0);\n    if (server_fd < 0) {\n        perror ("socket");\n        return -1;\n    }\n    tmp = 1;\n    setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &tmp, sizeof(tmp));\n    if (bind (server_fd, (struct sockaddr *) my_addr, sizeof (*my_addr)) < 0) {\n        char bindmsg[32];\n        snprintf(bindmsg, sizeof(bindmsg), "bind(port %d)", ntohs(my_addr->sin_port));\n        perror (bindmsg);\n        closesocket(server_fd);\n        return -1;\n    }\n    if (listen (server_fd, 5) < 0) {\n        perror ("listen");\n        closesocket(server_fd);\n        return -1;\n    }\n    ff_socket_nonblock(server_fd, 1);\n    return server_fd;\n}', 'int ff_socket_nonblock(int socket, int enable)\n{\n#ifdef HAVE_WINSOCK2_H\n   return ioctlsocket(socket, FIONBIO, &enable);\n#else\n   if (enable)\n      return fcntl(socket, F_SETFL, fcntl(socket, F_GETFL) | O_NONBLOCK);\n   else\n      return fcntl(socket, F_SETFL, fcntl(socket, F_GETFL) & ~O_NONBLOCK);\n#endif\n}']