本文整理汇总了C++中Proxy::Run方法的典型用法代码示例。如果您正苦于以下问题:C++ Proxy::Run方法的具体用法?C++ Proxy::Run怎么用?C++ Proxy::Run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Proxy
的用法示例。
在下文中一共展示了Proxy::Run方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
const char* short_options = "b:a:p:k:c:f:s:u:hd";
struct option long_options[] = {
{ "bind", 1, NULL, 'b' },
{ "addr", 1, NULL, 'a' },
{ "port", 1, NULL, 'p' },
{ "key", 1, NULL, 'k' },
{ "cert", 1, NULL, 'c' },
{ "file", 1, NULL, 'f' },
{ "daemon", 0, NULL, 'd' },
{ "server", 0, NULL, 's' },
{ "ue", 0, NULL, 'u' },
{ "help", 0, NULL, 'h' },
{ 0, 0, 0, 0},
};
int c;
while((c = getopt_long (argc, argv, short_options, long_options, NULL)) != -1)
{
switch (c)
{
case 'b':
g_bind_port = strtoul(optarg, NULL, 0);
break;
case 'a':
g_proxy_host = optarg;
break;
case 'p':
g_proxy_port = strtoul(optarg, NULL, 0);
break;
case 'k':
g_key_path.assign(optarg);
break;
case 'c':
g_cert_path.assign(optarg);
break;
case 'f':
g_data_file.assign(optarg);
break;
case 's':
g_replaceServ.assign(optarg);
break;
case 'u':
g_replaceUE.assign(optarg);
break;
case 'd':
g_daemon = true;
break;
case 'h':
usage();
return 0;
default:
printf("unkown type %c\n", c);
break;
}
}
if (g_daemon && Daemon() < 0)
{
return -1;
}
BugReportRegister(argv[0], ".", NULL, NULL);
SetSignal();
g_logFp = fopen(LOG_FILE, "w");
if (g_logFp == NULL)
{
printf("can't open log file %s\n", LOG_FILE);
return -1;
}
if (g_key_path.empty())
g_key_path = g_cert_path;
if (!g_data_file.empty())
{
g_dataFp = fopen(g_data_file.c_str(), "w");
if (g_dataFp == NULL)
{
PrintLog(g_logFp, "can't open log file %s\n", g_data_file.c_str());
fclose(g_logFp);
return -1;
}
}
PrintLog(g_logFp, "proxy is run...\n");
Proxy proxy;
proxy.Run(g_bind_port);
if (g_dataFp)
{
fclose(g_dataFp);
g_dataFp = NULL;
}
PrintLog(g_logFp, "proxy is exit...\n");
//.........这里部分代码省略.........