本文整理汇总了C++中run_server函数的典型用法代码示例。如果您正苦于以下问题:C++ run_server函数的具体用法?C++ run_server怎么用?C++ run_server使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run_server函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ndn_rtt
int ndn_rtt(int argc, char **argv)
{
if (argc < 2) {
printf("usage: %s [client|server]\n", argv[0]);
return 1;
}
if (strcmp(argv[1], "client") == 0) {
if (argc < 3) {
printf("usage: %s client _max_count_\n", argv[0]);
return 1;
}
int max_cnt = atoi(argv[2]);
if (max_cnt == 0) {
printf("invalid max count number: %s\n", argv[3]);
return 1;
}
run_client(max_cnt);
}
else if (strcmp(argv[1], "server") == 0) {
if (argc < 4) {
printf("usage: %s server _sig_type_ _content_size_\n", argv[0]);
return 1;
}
int content_sz = atoi(argv[3]);
if (content_sz <= 0 || content_sz > 200) {
printf("invalid content size: %s; will set to 4\n", argv[3]);
content_sz = 4;
}
if (strcmp(argv[2], "hmac") == 0) {
run_server(NDN_SIG_TYPE_HMAC_SHA256, content_sz);
}
else if (strcmp(argv[2], "ecdsa") == 0) {
run_server(NDN_SIG_TYPE_ECDSA_SHA256, content_sz);
}
else {
printf("unknown signature type: %s\n", argv[2]);
return 1;
}
}
else {
puts("error: invalid command");
}
return 0;
}
示例2: Argument_main
int Argument_main(Argument *arg){
gint port, max_connections, verbosity;
gchar *input_path;
gboolean preload;
register ArgumentSet *as = ArgumentSet_create("Exonerate Server options");
ArgumentSet_add_option(as, '\0', "port", "port",
"Port number to run server on", "12886",
Argument_parse_int, &port);
ArgumentSet_add_option(as, '\0', "input", "path",
"Path to input file (.esd or .esi)", NULL,
Argument_parse_string, &input_path);
ArgumentSet_add_option(as, '\0', "preload", NULL,
"Preload index and sequence data", "TRUE",
Argument_parse_boolean, &preload);
ArgumentSet_add_option(as, '\0', "maxconnections", "threads",
"Maximum concurrent server connections", "4",
Argument_parse_int, &max_connections);
ArgumentSet_add_option(as, 'V', "verbosity", "level",
"Set server verbosity level", "1",
Argument_parse_int, &verbosity);
Argument_absorb_ArgumentSet(arg, as);
/**/
Match_ArgumentSet_create(arg);
HSPset_ArgumentSet_create(arg);
/**/
Argument_process(arg, "exonerate-server", "Exonerate Server.\n",
"Guy St.C. Slater. [email protected] June 2006\n");
run_server(port, input_path, preload, max_connections, verbosity);
g_message("-- server exiting");
return 0;
}
示例3: main
int main(int argc, char **argv)
{
if (argc > 1 && strcmp(argv[1], "test") == 0)
return run_tests(argc, argv);
return run_server(argc, argv);
}
示例4: main
int main()
{
int * pipe_req = pipe_create();
int * pipe_ans = pipe_create();
pid_t fork_res = fork();
switch(fork_res)
{
case -1: printf("Stopped. Fork error.\n");
break;
case 0: close(pipe_req[1]);
close(pipe_ans[0]);
run_server(pipe_req[0], pipe_ans[1]);
close(pipe_req[0]);
close(pipe_ans[1]);
break;
default: close(pipe_req[0]);
close(pipe_ans[1]);
run_client(pipe_req[1], pipe_ans[0]);
close(pipe_req[1]);
close(pipe_ans[0]);
break;
};
pipe_delete(pipe_req);
pipe_delete(pipe_ans);
return 0;
}
示例5: run_server
void run_server_or_cgi::run()
{
bool server=false;
for (int i=1; i<argc; i++)
if (argv[i]==string("-s")||
argv[i]==string("--server"))
server=true;
if (server){
run_server(c, argc, argv).run();
}
else{
bool help=false;
for (int i=1; i<argc; i++)
if (argv[i]==string("-h")||
argv[i]==string("--help"))
help=true;
if (help){
cerr<<"usage: "<<argv[0]<<" [-s] [-h] [server-options]"<<endl;
exit(0);
}
run_cgi(c).run();
}
}
示例6: wait_thread
void* wait_thread(void* args)
{
int status;
while(running_flag) {
//Start server
pthread_mutex_lock(&fd_mutex);
server_pid = run_server();
if(server_pid == -1) {
pthread_mutex_unlock(&fd_mutex);
printlog(LOG_SERVER, "Failed to run server!\n");
continue;
}
pthread_mutex_unlock(&fd_mutex);
printlog(LOG_SERVER, "Server started.\n");
//Wait
waitpid(server_pid, &status, 0);
}
UNREFERRED_PARAMETER(args);
return NULL;
}
示例7: main
int
main(int argc, char **argv)
{
int loop_number = 0;
startup_win_network();
parse_parameters(argc, argv);
init_network();
signal(SIGINT, sig_handler);
if (!quiet)
{
fprintf(stderr, "listening on port %d for packets .... \n", port_num);
if (continuous)
fprintf(stderr, "looping tests.\n");
fprintf(stderr, "\n");
}
fprintf(stdout, "# run no., loss rate in %%, packets_sent, packets_received, payload_size\n");
do
{
loop_number++;
fprintf(stdout, "%2d. ", loop_number);
run_server();
}
while (continuous);
return 1;
}
示例8: main
int main(int argc, char *argv[]){
int server;
int port = DEFAULT_PORT;
int c;
opterr = 0;
while ((c = getopt (argc, argv, "sp:")) != -1){
switch (c){
case 's':
server = 1;
break;
case 'p':
port = atoi(optarg);
break;
default:
fprintf(stderr, "undefined argument\n");
exit(1);
}
}
if (server){
run_server(port);
} else {
run_client(port);
}
return 0;
}
示例9: _tmain
int _tmain(int argc, TCHAR *argv[])
{
int res = 0;
program_state_t state;
if (argc != 4) {
_tprintf(_T("Usage: %s <port> <in folder> <num of threads>\n"), argv[0]);
return -1;
}
state.port = _tstoi(argv[1]);
_tcscpy_s(state.in_dir, argv[2]);
state.num_of_threads = _tstoi(argv[3]);
if (!init_state(&state)) {
res = -1;
goto cleanup;
}
if (!run_server(&state)) {
res = -1;
}
cleanup:
if (!fini_state(&state)) {
res = -1;
}
return res;
}
示例10: server
int server(struct conf *conf, const char *conffile,
struct lock *lock, int generate_ca_only)
{
int ret=0;
int rfd=-1; // normal client port
// Only close and reopen listening sockets if the ports changed.
// Otherwise you get an "unable to bind listening socket on port X"
// error, and the server stops.
char *oldport=NULL;
char *oldstatusport=NULL;
//return champ_test(conf);
if(ca_server_setup(conf)) return 1;
if(generate_ca_only)
{
logp("The '-g' command line option was given. Exiting now.\n");
return 0;
}
if(conf->forking && conf->daemon)
{
if(daemonise() || relock(lock)) return 1;
}
ssl_load_globals();
while(!ret && !gentleshutdown)
{
ret=run_server(conf, conffile,
&rfd, oldport, oldstatusport);
if(ret) break;
if(hupreload && !gentleshutdown)
{
if(oldport) free(oldport);
if(oldstatusport) free(oldstatusport);
oldport=strdup(conf->port);
oldstatusport=conf->status_port?
strdup(conf->status_port):NULL;
if(reload(conf, conffile,
0, // Not first time.
conf->max_children,
conf->max_status_children,
0)) // Not JSON output.
ret=1;
}
hupreload=0;
}
close_fd(&rfd);
close_fd(&sfd);
if(oldport) free(oldport);
if(oldstatusport) free(oldstatusport);
// The signal handler stuff sets up chlds. Need to free them.
chlds_free();
// FIX THIS: Have an enum for a return value, so that it is more obvious what
// is happening, like client.c does.
return ret;
}
示例11: main
int
main(int argc, char *argv[])
{
in_port_t port;
uint8_t page_count;
if (argc > 3) {
printf("Too many arguments\n");
return -1;
}
if (argc < 3) {
printf("Not enough arguments (port, pages)\n");
return -1;
}
if (sscanf(argv[1], "%"SCNu16, &port) != 1) {
printf("Bad port\n");
return -1;
}
if (sscanf(argv[2], "%"SCNu8, &page_count) != 1) {
printf("Bad page number\n");
return -1;
}
return run_server(port, page_count, xen_shm_handler_ping_server, NULL);
}
示例12: main
int main(int argc, const char **argv)
{
clioptions opts;
parse_commandline(argc, argv, &opts);
run_server(&opts);
return 0;
}
示例13: main
int main(char argc, char *argv[]){
if( args_handle(argc,argv) != -1 ){
run_server(OPTION_PORT);
}
return 0;
}
示例14: ServiceMain
void CALLBACK ServiceMain(DWORD dwArgc, LPTSTR *lpszArgv)
{
int seq=1;
HKEY hk;
DWORD dwTmp,dwType;
char szTmp[1024];
HANDLE hSem = CreateSemaphore(NULL,0,1,"CVSNT_ControlPanel");
if(dwArgc!=999)
{
if (!(g_hService = RegisterServiceCtrlHandler(SERVICE_NAME,ServiceHandler))) { ReportError(TRUE,"Unable to start "SERVICE_NAME" - RegisterServiceCtrlHandler failed"); return; }
NotifySCM(SERVICE_START_PENDING, 0, seq++);
}
else
{
g_bTestMode=TRUE;
printf(SERVICE_NAME" " CVSNT_PRODUCTVERSION_STRING " ("__DATE__") starting in test mode.\n");
}
// Initialisation
WSADATA data;
if(WSAStartup (MAKEWORD (1, 1), &data))
{
ReportError(TRUE,"WSAStartup failed... aborting - Error %d\n",WSAGetLastError());
if(!g_bTestMode)
NotifySCM(SERVICE_STOPPED,0,0);
return;
}
if(!RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\CVS\\Pserver",NULL,KEY_QUERY_VALUE,&hk))
{
dwTmp=sizeof(szTmp);
if(!RegQueryValueEx(hk,"ControlPanel",NULL,&dwType,(BYTE*)szTmp,&dwTmp))
{
char *p = strchr(szTmp,':');
if(p)
controlserver_port=atoi(p+1);
}
dwTmp=sizeof(szTmp);
if(!RegQueryValueEx(hk,"ControlPanelLocal",NULL,&dwType,(BYTE*)szTmp,&dwTmp))
{
if(dwType==REG_DWORD)
local_only = *(DWORD*)szTmp;
}
RegCloseKey(hk);
}
run_server(controlserver_port, seq, local_only);
CloseHandle(hSem);
if(!g_bTestMode)
NotifySCM(SERVICE_STOPPED, 0, 0);
ReportError(FALSE,SERVICE_NAME" stopped successfully");
}
示例15: main
/*---------------------------------------------------------------------------------------
-- FUNCTION: main
--
-- DATE: February 11, 2016
--
-- DESIGNERS: Rizwan Ahmed, Vishav Singh
--
-- PROGRAMMERS: Rizwan Ahmed, Vishav Singh
--
-- RETURNS: 0 on exit
--
-- NOTES: Main entry point of the program. Merely gets rid of the need to flush
-- everytime something is printed to standard output and calls the server loop.
---------------------------------------------------------------------------------------*/
int main(int argc, char *argv[])
{
(void)signal(SIGINT, kill_server);
setbuf(stdout, NULL);
run_server(SERVER_PORT);
return 0;
}