XBMC研究之web server

  1. 转载自http://blog.sina.com.cn/s/blog_6c14c17e0100lny0.html

上篇博文中讲到GUI上用JSON脚本发送一个请求时,会调用AnswerToConnection函数来进行应答。其实此函数是在呼叫MHD_start_daemon时,作为callback函数传入libmicrohttpd的,MHD_start_daemon是libmicrohttpd的守护入口。
       那么这篇博文将介绍XBMC的Web Server,首先我们看看Web Server的启动:
        bool CWebServer::Start(const char *ip, int port)
    {
        if (!m_running)
        {
            // To stream perfectly we should probably have MHD_USE_THREAD_PER_CONNECTION instead of MHD_USE_SELECT_INTERNALLY as it provides multiple clients concurrently
            m_daemon = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY | MHD_USE_IPv6, port, NULL, NULL, &CWebServer::AnswerToConnection, this, MHD_OPTION_END);
            if (!m_daemon) //try IPv4
                m_daemon = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY, port, NULL, this, &CWebServer::AnswerToConnection, this, MHD_OPTION_END);
            m_running = m_daemon != NULL;
            if (m_running)
                CLog::Log(LOGNOTICE, "WebServer: Started the webserver");
            else
                CLog::Log(LOGERROR, "WebServer: Failed to start the webserver");
        }
        return m_running;
    }
       关闭web server守护:
    bool CWebServer::Stop()
    {
        if (m_running)
        {
            MHD_stop_daemon(m_daemon);
            m_running = false;
            CLog::Log(LOGNOTICE, "WebServer: Stopped the webserver");
        }
        return !m_running;
    }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值