本文整理汇总了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;
}
示例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";
}