当前位置: 首页>>代码示例>>C++>>正文


C++ SocketServer::run方法代码示例

本文整理汇总了C++中SocketServer::run方法的典型用法代码示例。如果您正苦于以下问题:C++ SocketServer::run方法的具体用法?C++ SocketServer::run怎么用?C++ SocketServer::run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SocketServer的用法示例。


在下文中一共展示了SocketServer::run方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: serverCallback

static void* serverCallback(void* arg)
{
  try
    {
      ServerData* data = static_cast<ServerData*>(arg);
      SocketServer* server = new SocketServer;
      std::string host = "127.0.0.1";
      if (!data->isServer)
	  host = "127.0.0.2";

      server->run(serverHandleCallback, host);
      delete server;
      data->serverThread->exit();
    }
  catch (ISocket::Exception& e)
    {
      std::cerr << e.what() << std::endl; 
    }

  return NULL;
}
开发者ID:Bootz,项目名称:VoIP_Project_archive,代码行数:21,代码来源:main.cpp

示例2: main

int main (int argc, char * argv [])
{
    int i = 0;
    bool daemon = true;

    while (i<argc) {
        if (++i >= argc) break;

        if (String ("-nd") == argv [i] ||
            String ("--no-daemon") == argv [i]) {
            daemon = false;
            continue;
        }

        if (String ("-v") == argv [i] ||
            String ("--verbose") == argv [i]) {
            if (++i >= argc) {
                std::cerr << "No argument for option " << argv [i-1] << "\n";
                return -1;
            }
            DebugOutput::set_verbose_level (atoi (argv [i]));
            continue;
        }

        if (String ("-m") == argv [i] ||
            String ("--mask") == argv [i]) {
            if (++i >= argc) {
                std::cerr << "No argument for option " << argv [i-1] << "\n";
                return -1;
            }
            if (String (argv [i]) != "none") {
                std::vector<String> debug_mask_list;
                scim_split_string_list (debug_mask_list, argv [i], ',');
                DebugOutput::disable_debug (SCIM_DEBUG_AllMask);
                for (size_t j=0; j<debug_mask_list.size (); j++)
                    DebugOutput::enable_debug_by_name (debug_mask_list [j]);
            }
            continue;
        }

        if (String ("-o") == argv [i] ||
            String ("--output") == argv [i]) {
            if (++i >= argc) {
                std::cerr << "No argument for option " << argv [i-1] << "\n";
                return -1;
            }
            DebugOutput::set_output (String (argv [i]));
            continue;
        }

        std::cerr << "Invalid command line option: " << argv [i] << "\n";
        return -1;
    } //End of command line parsing.

    load_helper_modules ();

    if (!initialize_socket_server ()) {
        std::cerr << "Can't initialize SocketServer.\n";
        return -1;
    }

    if (daemon) scim_daemon ();

    signal(SIGQUIT, signalhandler);
    signal(SIGTERM, signalhandler);
    signal(SIGINT,  signalhandler);
    signal(SIGHUP,  signalhandler);

    __socket_server.run ();

    SCIM_DEBUG_MAIN (1) << "exit scim-helper-manager.\n";
}
开发者ID:sillsdev,项目名称:scim,代码行数:72,代码来源:scim_helper_manager_server.cpp


注:本文中的SocketServer::run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。