• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ server函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中server函数的典型用法代码示例。如果您正苦于以下问题:C++ server函数的具体用法?C++ server怎么用?C++ server使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: main


//.........这里部分代码省略.........
        opterr = 1;
        argList.append(argv[0]);
        if (!norc) {
            String rc = Path("/etc/rdmrc").readAll();
            if (!rc.isEmpty()) {
                for (const String& s : rc.split('\n')) {
                    if (!s.isEmpty() && !s.startsWith('#'))
                        argCopy += s.split(' ');
                }
            }
            if (!rcfile.isEmpty()) {
                rc = rcfile.readAll();
                if (!rc.isEmpty()) {
                    for (const String& s : rc.split('\n')) {
                        if (!s.isEmpty() && !s.startsWith('#'))
                            argCopy += s.split(' ');
                    }
                }
            }
            const int s = argCopy.size();
            for (int i=0; i<s; ++i) {
                String &arg = argCopy.at(i);
                if (!arg.isEmpty())
                    argList.append(arg.data());
            }
        }

        for (int i=1; i<argc; ++i)
            argList.append(originalArgv[i]);

        optind = 1;
    }

    Server::Options serverOpts;
    serverOpts.threadStackSize = defaultStackSize;
    serverOpts.socketFile = String::format<128>("%s.rdm", Path::home().constData());
    serverOpts.jobCount = std::max(2, ThreadPool::idealThreadCount());
    serverOpts.headerErrorJobCount = -1;
    serverOpts.rpVisitFileTimeout = DEFAULT_RP_VISITFILE_TIMEOUT;
    serverOpts.rpIndexDataMessageTimeout = DEFAULT_RP_INDEXER_MESSAGE_TIMEOUT;
    serverOpts.rpConnectTimeout = DEFAULT_RP_CONNECT_TIMEOUT;
    serverOpts.rpConnectAttempts = DEFAULT_RP_CONNECT_ATTEMPTS;
    serverOpts.maxFileMapScopeCacheSize = DEFAULT_RDM_MAX_FILE_MAP_CACHE_SIZE;
    serverOpts.rpNiceValue = INT_MIN;
    serverOpts.options = Server::Wall|Server::SpellChecking;
    serverOpts.maxCrashCount = DEFAULT_MAX_CRASH_COUNT;
    serverOpts.completionCacheSize = DEFAULT_COMPLETION_CACHE_SIZE;
    serverOpts.rp = defaultRP();
#ifdef OS_FreeBSD
    serverOpts.options |= Server::NoFileManagerWatch;
#endif
// #ifndef NDEBUG
//     serverOpts.options |= Server::SuspendRPOnCrash;
// #endif
    serverOpts.dataDir = String::format<128>("%s.rtags", Path::home().constData());

    const char *logFile = 0;
    Flags<LogFlag> logFlags = DontRotate|LogStderr;
    LogLevel logLevel(LogLevel::Error);
    LogLevel logFileLogLevel(LogLevel::Error);
    bool sigHandler = true;
    assert(Path::home().endsWith('/'));
    int argCount = argList.size();
    char **args = argList.data();
    bool defaultDataDir = true;
    int inactivityTimeout = 0;
开发者ID:LuXuryPro,项目名称:rtags,代码行数:67,代码来源:rdm.cpp


示例2: main

int main() {
    
    char *customData = getCustomRecordedGameData();

    initDrawString( w, h );
    
    initFrameDrawer( w, h, 60,
                     customData, false );
    
    delete [] customData;
    

    initSimulator();
    
    int port = 
        SettingsManager::getIntSetting( "simulatorServerPort", 5077 );

    char *password = 
        SettingsManager::getStringSetting( "simulatorServerPassword" );
    
    if( password == NULL ) {
        password = stringDuplicate( "secret" );
        }
    

    
    SocketServer server( port, 256 );

    char quit = false;
    
    while( !quit ) {
        printf( "Waiting for connection on port %d, password = '%s'\n", 
                port, password );

        Socket *sock = server.acceptConnection();
        
        if( sock != NULL ) {
            printf( "Got connection\n" );

            char *request = readFullRequest( sock );
            
            if( request != NULL ) {

                char *response = NULL;

                if( strstr( request, "quit" ) == request ) {
                    // starts with quit
                
                    if( strstr( request, password ) != NULL ) {
                        quit = true;
                    
                        response = stringDuplicate( "OK" );
                        }
                    else {
                        response = stringDuplicate( "FAILED" );
                        }
                    }
                else if( strstr( request, "check_alive" ) == request ) {
                    response = stringDuplicate( "OK" );
                    }
                else if( strstr( request, "simulate_robbery" ) == request ) {
                    double startTime = Time::getCurrentTime();
                
                    response = simulateRobbery( request );
                    
                    double netTime = Time::getCurrentTime() - startTime;
                    printf( "Simulation took %f seconds\n", netTime );
                    }
                else {
                    response = stringDuplicate( "FAILED" );
                    }
            

                delete [] request;
            
                sock->send( (unsigned char *)response, strlen( response ), 
                            true, false );
            
                delete [] response;


                sock->send( (unsigned char *)"\n", strlen( "\n" ), 
                            true, false );


                sock->send( (unsigned char *)END_RESPONSE, 
                            strlen( END_RESPONSE ), 
                            true, false );


                sock->sendFlushBeforeClose( 3000 );
                }
            
            delete sock;
            }
        }
    
    delete [] password;
    
    freeSimulator();
//.........这里部分代码省略.........
开发者ID:MrPhil,项目名称:CastleDoctrine,代码行数:101,代码来源:headlessGamePlatform.cpp


示例3: server

void TestThemeDaemonServerThread::run()
{
    TestThemeDaemonServer server(m_serverAddress, m_pixmapCache);
    exec();
}
开发者ID:AfterTheRainOfStars,项目名称:qt-components,代码行数:5,代码来源:testthemedaemonserverthread.cpp


示例4: main

int main()
{
	CServer server(SERVER_PORT);

	// -------------------------------------------------------------------------

	printf("--- Client ---\n");
	CClient client;
	client.Init("127.0.0.1", SERVER_PORT);

	// -------------------------------------------------------------------------

	//	uint logDelay = 1000 * 60 * 30;
	uint logDelay = 5;
	time_t deadline = 0;
	bool readFlag = false;

	/*
	byte args[] = { 0, 8, 0, 1, 2, 3, 4, 5, 6, 7 };
	g_commMgr->PushCommand(CMD_WRITE_EEPROM, &args, sizeof(args));
	*/

//	arduinoCmdManager.SendCommand(&arduinoPort, CMD_REQUEST_ONE_WIRE_ENUM, NULL, 0);
	
	while (true)
	{
		server.OnUpdate();
		client.OnUpdate();
		
		System::SleepMS(0);
		/*
		if (false == readFlag)
		{
			if (true == device->IsOneWireEnumerated())
			{
				//OnEnumerationDone();
				readFlag = true;

				// test "turn on relay"
				//byte data[] = { 4, 0 };
				//arduinoCmdManager.SendCommand(&arduinoPort, CMD_PIN_WRITE, &data, sizeof(data));
			}
		}

		if (true == readFlag)
		{
			const time_t currentTime = time(NULL);
			if (currentTime >= deadline)
			{
				deadline = (currentTime + logDelay);
				OneWireAddr addr = device->GetOneWireDevice(0);

				arduinoCmdManager.SendCommand(
					&arduinoPort,
					CMD_OW_READ_TEMP_SENSOR_DATA,
					addr.Address(),
					OneWireAddr::ADDR_LEN);
			}
		}
		*/
	}

//	comPort.Close();
	return 0;
}
开发者ID:wolves3d,项目名称:RoomControl,代码行数:65,代码来源:main.cpp


示例5: server

	~compress_plugin() {
		server().onPostProcess.disconnect(postProcess_);
	}
开发者ID:hiwang123,项目名称:x0,代码行数:3,代码来源:compress.cpp


示例6: start_nodes

nodes_data::ptr start_nodes(std::ostream &debug_stream, const std::vector<config_data> &configs, const std::string &path)
{
	nodes_data::ptr data = std::make_shared<nodes_data>();

	std::string base_path;
	std::string auth_cookie;
	std::string cocaine_config_template = read_file(COCAINE_CONFIG_PATH);
	std::string run_path;

	{
		char buffer[1024];

		snprintf(buffer, sizeof(buffer), "%04x%04x", rand(), rand());
		buffer[sizeof(buffer) - 1] = 0;
		auth_cookie = buffer;

		snprintf(buffer, sizeof(buffer), "/tmp/elliptics-test-run-%04x/", rand());
		buffer[sizeof(buffer) - 1] = 0;
		run_path = buffer;
	}

	const auto ports = generate_ports(configs.size());

	if (path.empty()) {
		char buffer[1024];

		snprintf(buffer, sizeof(buffer), "/tmp/elliptics-test-%04x/", rand());
		buffer[sizeof(buffer) - 1] = 0;
		base_path = buffer;

		create_directory(base_path);
		data->directory = directory_handler(base_path, true);
	} else {
		base_path = path;

		create_directory(base_path);
		data->directory = directory_handler(base_path, false);
	}

	debug_stream << "Set base directory: \"" << base_path << "\"" << std::endl;

	create_directory(run_path);
	data->run_directory = directory_handler(run_path, true);
	debug_stream << "Set cocaine run directory: \"" << run_path << "\"" << std::endl;

	std::string cocaine_remotes;
	for (size_t j = 0; j < configs.size(); ++j) {
		if (j > 0)
			cocaine_remotes += ", ";
		cocaine_remotes += "\"localhost\": " + ports[j];
	}

	const auto cocaine_locator_ports = generate_ports(configs.size());
	// client only needs connection to one (any) locator service
	data->locator_port = std::stoul(cocaine_locator_ports[0]);

	debug_stream << "Starting " << configs.size() << " servers" << std::endl;

	for (size_t i = 0; i < configs.size(); ++i) {
		debug_stream << "Starting server #" << (i + 1) << std::endl;

		const std::string server_path = base_path + "/server-" + boost::lexical_cast<std::string>(i + 1);

		create_directory(server_path);
		create_directory(server_path + "/blob");
		create_directory(server_path + "/history");

		std::string remotes;
		for (size_t j = 0; j < configs.size(); ++j) {
			if (j == i)
				continue;

			remotes += create_remote(ports[j]);
		}

		config_data config = configs[i];
		if (remotes.empty())
			config("remote", NULL_VALUE);
		else
			config("remote", remotes);

		if (config.has_value("srw_config")) {
			create_directory(server_path + "/run");

			const substitute_context cocaine_variables = {
				{ "COCAINE_LOCATOR_PORT", cocaine_locator_ports[i] },
				{ "COCAINE_PLUGINS_PATH", COCAINE_PLUGINS_PATH },
				{ "ELLIPTICS_REMOTES", cocaine_remotes },
				{ "ELLIPTICS_GROUPS", "1" },
				{ "COCAINE_LOG_PATH", server_path + "/cocaine.log" },
				{ "COCAINE_RUN_PATH", run_path }
			};
			create_cocaine_config(server_path + "/cocaine.conf", cocaine_config_template, cocaine_variables);

			config("srw_config", server_path + "/cocaine.conf");
		}

		create_config(config, server_path + "/ioserv.conf")
				("auth_cookie", auth_cookie)
				("log", server_path + "/log.log")
//.........这里部分代码省略.........
开发者ID:hungld,项目名称:elliptics,代码行数:101,代码来源:test_base.cpp


示例7: XBL_MM_QuickMatch

// Search for and join a good online server
// GameType is optional - X_MATCH_NULL_INTEGER to omit
bool XBL_MM_QuickMatch(ULONGLONG GameType)
{
	// Reuse our optimatch query object. VVFIXME - needs to be torn down first?

	HRESULT hr = query.Query(
		GameType,
		X_MATCH_NULL_INTEGER,		// CurrentMap
		0,							// MinimumPlayers
		8,							// MaximumPlayers
		X_MATCH_NULL_INTEGER,		// FriendlyFire
		X_MATCH_NULL_INTEGER,		// JediMastery
		X_MATCH_NULL_INTEGER,		// SaberOnly
		X_MATCH_NULL_INTEGER);		// Dedicated
	if ( FAILED( hr ) )
	{
		UI_xboxErrorPopup( XB_POPUP_MATCHMAKING_ERROR );
		return false;
	}
	// Keep servicing the query until it completes.
	// The logon task must also be serviced in order to remain connected. 
	do
	{
		if( !XBL_PumpLogon() )
			return false;
		hr = query.Process();
	} while( query.IsRunning() );

	if( !query.Succeeded() )
	{
		UI_xboxErrorPopup( XB_POPUP_MATCHMAKING_ERROR );
		return false;
	}

	// VVFIXME - Need to do probing, and pick best session, not just the first one
	if (!query.Results.Size())
	{
		UI_xboxErrorPopup( XB_POPUP_QUICKMATCH_NO_RESULTS );
		return false;
	}

	COptiMatchResult &server(query.Results[0]);

	XBL_MM_SetJoinType( VIA_QUICKMATCH );
	// VVFIXME - Experiment, leave this out so that the screen doesn't get trashed
	// right as we connect?
//	Menus_CloseAll();
	Net_XboxConnect(&server.SessionID, &server.KeyExchangeKey, &server.HostAddress);
/*
    // warn of lag and join(or not) via ui
    //
    if( cls.globalServers[bestSesh].ping < MINIMUM_QOS )
    {
        joinServerSlot = bestSesh;
	    Cvar_Set(CVAR_UI_XBOXREBOOTTITLE, " ");
        Cvar_Set(CVAR_UI_XBOXREBOOTMESSAGE, StringTable_Get(XSTR_GAMEPLAY_AFFECTED_BY_NETWORK));
		//Menus_ActivateByName("ingame_small_bgd");
        Menus_CloseByName("quickmatch_popup");
        Menus_ActivateByName("xblive_slow_warning");
       return false;
    }
    XBL_MM_JoinServer( bestSesh );
*/
	return true;
}
开发者ID:3ddy,项目名称:Jedi-Academy,代码行数:66,代码来源:XBLive_MM.cpp


示例8: main

int main( int argc, char** argv ) {
  try {
  Wt::WServer server("ltl::server");
  server.setServerConfiguration( argc, argv, WTHTTP_CONFIGURATION );

  boost::filesystem::create_directories("db");
  ltl::server::ptr ms( new ltl::server( "db") );
  ltl::dbo::ptr<ltl::identity>   dan                 = ms->create_identity( "dan", "danprops" );
  ltl::dbo::ptr<ltl::identity>   scott               = ms->create_identity( "scott", "scottprops" );
  ltl::dbo::ptr<ltl::asset>      corn                = ms->create_asset( "corn", "gmo" );
  ltl::dbo::ptr<ltl::asset>      dollar              = ms->create_asset( "dollar", "$USD" );
  ltl::dbo::ptr<ltl::asset_note> dans_corn           = ms->create_asset_note(dan, corn, "dans corn", "cool" ); 
  ltl::dbo::ptr<ltl::asset_note> scott_dollar        = ms->create_asset_note(scott, dollar, "scott dollarn", "awesome" ); 

  ltl::dbo::ptr<ltl::account> dans_dans_corn_acnt       = ms->create_account( dan, dans_corn );
  ltl::dbo::ptr<ltl::account> scotts_dans_corn_acnt     = ms->create_account( scott, dans_corn );
  ltl::dbo::ptr<ltl::account> dans_scott_dollar_acnt    = ms->create_account( dan, scott_dollar );
  ltl::dbo::ptr<ltl::account> scotts_scott_dollar_acnt  = ms->create_account( scott, scott_dollar );

  try {
  // this should throw because scott has a 0 balance and cannot issue because he is not signer on note
  ltl::dbo::ptr<ltl::transaction> trx  = ms->transfer( "Sell corn", 10, scotts_dans_corn_acnt, dans_dans_corn_acnt );
  } catch ( const boost::exception& e ) {
    wlog("Expected Exception: %1%",boost::diagnostic_information(e));
  }

  slog( "creating first transaction" );
  // transfer 10 corn from dan_dans_corn to scotts_dans_corn
  ltl::dbo::ptr<ltl::transaction> trx  = ms->transfer( "Issue corn",10, dans_dans_corn_acnt, scotts_dans_corn_acnt );

  std::vector<ltl::sha1> req = trx->get_required_signatures();
  for( uint32_t i = 0; i < req.size(); ++i ) {
    slog( "required signature %1%", std::string(req[i]) );
  }

  slog( "Dan's Corn:\n%1%", dans_dans_corn_acnt->to_string() );
  slog( "Scott's Corn:\n%1%", scotts_dans_corn_acnt->to_string() );

  wlog( "Allocating Signature Numbers" );
  ms->allocate_signature_numbers( dans_dans_corn_acnt, 10 );
  ms->allocate_signature_numbers( scotts_dans_corn_acnt, 5 );
  ms->allocate_signature_numbers( dans_scott_dollar_acnt, 3 );
  ms->allocate_signature_numbers( scotts_scott_dollar_acnt, 3 );
  slog( "Dan's Corn:\n%1%", dans_dans_corn_acnt->to_string() );

  wlog( "Accepting Balance" );
  ms->accept_applied_transactions( dans_dans_corn_acnt );
  ms->accept_applied_transactions( scotts_dans_corn_acnt );
  ms->accept_applied_transactions( dans_scott_dollar_acnt );
  ms->accept_applied_transactions( scotts_scott_dollar_acnt );
  slog( "Dan's Corn:\n%1%", dans_dans_corn_acnt->to_string() );

  wlog( "Signing tranaction" );
  ms->sign_transaction( trx, dans_dans_corn_acnt );
  slog( "Dan's Corn:\n%1%", dans_dans_corn_acnt->to_string() );
  ms->sign_transaction( trx, scotts_dans_corn_acnt );
  slog( "Scott's Corn:\n%1%", scotts_dans_corn_acnt->to_string() );
  slog( "Dan's Corn:\n%1%", dans_dans_corn_acnt->to_string() );

  wlog( "Accepting Dan's Balance" );
  ms->accept_applied_transactions( dans_dans_corn_acnt );
  slog( "Dan's Corn:\n%1%", dans_dans_corn_acnt->to_string() );

  wlog( "Accepting Scott's Balance" );
  ms->accept_applied_transactions( scotts_dans_corn_acnt );
  slog( "Scott's Corn:\n%1%", scotts_dans_corn_acnt->to_string() );



  wlog( "Starting Market Order" );
  ltl::dbo::ptr<ltl::market_order> mo = ms->submit_order( ltl::market_order::buy, scotts_dans_corn_acnt, scotts_scott_dollar_acnt,
                    1000,  313, 1, ltl::to_ptime( boost::chrono::system_clock::now() ), ltl::to_ptime( boost::chrono::system_clock::now() + boost::chrono::minutes(60*24*30) ) );
  slog( "Scott's Corn:\n%1%", scotts_dans_corn_acnt->to_string() );
  slog( "Scott's Dollars:\n%1%", scotts_scott_dollar_acnt->to_string() );
  slog( "Dan's Corn:\n%1%", dans_dans_corn_acnt->to_string() );
  slog( "Dan's Dollars:\n%1%", dans_scott_dollar_acnt->to_string() );
 // trx->sign( dans_dans_corn_acnt );
  

  // at this point both dan & scott should have a pending, unsigned transaction in their inbox

  if( server.start() ) {
    int sig = Wt::WServer::waitForShutdown();
    std::cerr << "Shutting down (signal = " << sig <<")\n";
    server.stop();
  }

  } catch ( const boost::exception& e ) {
    std::cerr<<boost::diagnostic_information(e);
  } catch ( const std::exception& e ) {
    std::cerr<<boost::diagnostic_information(e);
  } catch ( ... ) {
    std::cerr<<"Unhandled exception\n";
  }
}
开发者ID:bytemaster,项目名称:ltl,代码行数:95,代码来源:main.cpp


示例9: respond

void SmtpAuth::execute()
{
    if ( !d->m ) {
        if ( server()->dialect() == SMTP::Lmtp ) {
            respond( 503, "Will not authenticate for LMTP", "5.5.0" );
            finish();
            return;
        }

        if ( server()->user() ) {
            respond( 503, "Already authenticated", "5.0.0" );
            finish();
            return;
        }

        if ( !server()->accessPermitted() ) {
            respond( 504, "TLS required for message submission", "5.7.0" );
            finish();
            return;
        }

        d->m = SaslMechanism::create( d->mech, this, server() );
        if ( !d->m ) {
            respond( 504, "Mechanism " + d->mech.quoted() + " not available",
                     "5.5.4" );
            finish();
            return;
        }

        server()->setInputState( SMTP::Sasl );
        d->m->readInitialResponse( d->r );
    }

    if ( d->m )
        d->m->readResponse( server()->readBuffer()->removeLine() );

    if ( !d->m->done() )
        return;

    if ( d->m->state() == SaslMechanism::Succeeded ) {
        if ( d->m->user()->login() == "anonymous" ) {
            respond( 235, "You may not submit mail", "2.0.0"  );
        }
        else {
            server()->authenticated( d->m->user() );
            respond( 235, "OK", "2.0.0" );
        }
    }
    else if ( d->m->state() == SaslMechanism::Terminated ) {
        respond( 501, "Authentication terminated", "5.0.0" );
    }
    else {
        respond( 535, "Authentication failed", "5.0.0" );
        if ( d->m->user() &&
             !d->m->user()->login().isEmpty() )
            log( "Authentication failed for " +
                 d->m->user()->login().ascii() );
        // huh. maybe we do want to use utf-8 in the logfile.
    }

    server()->setInputState( SMTP::Command );
    finish();
}
开发者ID:aox,项目名称:aox,代码行数:63,代码来源:smtpauth.cpp


示例10: main

int main( int argc, char * argv [] )
{
	boost::program_options::options_description optionsDescription( "options" );
	optionsDescription.add_options()
		("help", "produce help message")
		("objectStoreRootPath", boost::program_options::value< std::string >()->default_value( "/var/lib/osmosis/objectstore" ),
			"Path where osmosis will store objects. relevant for 'server', 'purge', 'labellog' and 'leastrecentlyused' commands" )
		("serverTCPPort", boost::program_options::value< unsigned short >()->default_value( 1010 ),
			"the TCP port to bind to, if command is 'server'")
		( "objectStores", boost::program_options::value< std::string >()->default_value( "127.0.0.1:1010" ),
			"the object store to act againt. May be a '+' seperated list for 'checkout' command" )
		( "MD5", "use MD5, not SHA1 for hash in 'checkin' operation" )
		( "putIfMissing", "when command is 'checkout' or 'transfer', this flag will cause any objects received not from the "
		        "nearest object store to be put into all objects stores up to the one it was fetched from" )
		( "removeUnknownFiles", "for checkout: remove files from disk that are not in the dirlist being checked out" )
		( "myUIDandGIDcheckout", "for checkout: use my uid and gid" )
		( "ignore", boost::program_options::value< std::string >(),
			"for checkout: ignore the existance of all files in this ':' seperated list. "
			"if a directory was specified, ignored everything under it as well. specified paths "
			"must reside inside the checkout path" )
		( "transferDestination", boost::program_options::value< std::string >(),
			"destination object store to transfer the label into" )
		( "reportFile", boost::program_options::value< std::string >()->default_value( "" ),
			"periodically write report in JSON format into this file" )
		( "reportIntervalSeconds", boost::program_options::value< unsigned >()->default_value( 15 ),
			"period to report progress" )
		( "noChainTouch", "avoid touching fetched label in all object stores in chain (used for label bookeeping)" )
		( "keep", boost::program_options::value< std::string >()->default_value( "keepforever|bootstrap" ),
		  	"regular expression for labels to never erase. Only relevant under 'leastrecentlyused' command" )
		( "maximumDiskUsage", boost::program_options::value< std::string >(),
		  	"<number>M or <number>G for the amount of storage used for label objects before 'leastrecentlyused' starts erasing labels");

	boost::program_options::options_description positionalDescription( "positionals" );
	positionalDescription.add_options()
		( "command", boost::program_options::value< std::string >() )
		( "arg1", boost::program_options::value< std::string >() )
		( "arg2", boost::program_options::value< std::string >() );

	boost::program_options::positional_options_description positionalMapping;
	positionalMapping.add( "command", 1 ).add( "arg1", 1 ).add( "arg2", 1 );

	boost::program_options::options_description allOptions;
	allOptions.add( optionsDescription ).add( positionalDescription );

	boost::program_options::variables_map options;
	try {
		boost::program_options::store(
			boost::program_options::command_line_parser( argc, argv ).
				positional( positionalMapping ).options( allOptions ).
				run(),
			options );
		boost::program_options::notify( options );
	} catch ( boost::exception & e ) {
		TRACE_BOOST_EXCEPTION( e, "Unable to parse command line" );
		usage( optionsDescription );
		return 1;
	}

	if ( options.count( "help" ) ) {
		usage( optionsDescription );
		return 1;
	}

	try {
		std::string command = options[ "command" ].as< std::string >();
		if ( command == "server" ) {
			if ( options.count( "arg1" ) > 0 or options.count( "arg2" ) > 0 ) {
				TRACE_ERROR( "'workDir' or 'label' must not be present in command line"
						"if 'server' is specified as the command" );
				usage( optionsDescription );
				return 1;
			}
			server( options );
		} else if ( command == "checkin" )
			checkIn( options );
		else if ( command == "checkout" )
			checkOut( options );
		else if ( command == "transfer" )
			transfer( options );
		else if ( command == "listlabels" )
			listLabels( options );
		else if ( command == "eraselabel" )
			eraseLabel( options );
		else if ( command == "purge" )
			purge( options );
		else if ( command == "renamelabel" )
			renameLabel( options );
		else if ( command == "labellog" )
			dumpLabelLog( options );
		else if ( command == "leastrecentlyused" )
			leastRecentlyUsed( options );
		else if ( command == "testhash" )
			testHash( options );
		else {
			TRACE_ERROR( "Unknown command '" << command << "'" );
			usage( optionsDescription );
			return 1;
		}
	} catch ( boost::exception & e ) {
		TRACE_BOOST_EXCEPTION( e, "Terminated on a boost exception" );
//.........这里部分代码省略.........
开发者ID:LightBitsLabs,项目名称:osmosis,代码行数:101,代码来源:main.cpp


示例11: main

int main(int argc, char * argv[]) {

    MPI_Init(&argc, &argv);

    MPI_Comm_rank(MPI_COMM_WORLD, &ThisTask);
    MPI_Comm_size(MPI_COMM_WORLD, &NTask);

    MPI_Type_contiguous(2, MPI_LONG, &MPI_TYPE_WORK);
    MPI_Type_commit(&MPI_TYPE_WORK);

    int ch;
    while(-1 != (ch = getopt(argc, argv, "n:N:vb:f:"))) {
        switch(ch) {
            case 'N':
            case 'n':
                Nfile = atoi(optarg);
                break;
            case 'b':
                sscanf(optarg, "%td", &buffersize);
                break;
            case 'f':
                newfilepath = optarg;
                break;
            case 'v':
                verbose = 1;
                break;
            default:
                usage();
        }
    }
    if(argc - optind + 1 != 4) {
        usage();
    }
    argv += optind - 1;
    if(0 != big_file_mpi_open(&bf, argv[1], MPI_COMM_WORLD)) {
        fprintf(stderr, "failed to open: %s\n", big_file_get_error_message());
        exit(1);
    }
    if(0 != big_file_mpi_open_block(&bf, &bb, argv[2], MPI_COMM_WORLD)) {
        fprintf(stderr, "failed to open: %s\n", big_file_get_error_message());
        exit(1);
    }
    if(Nfile == -1 || bb.Nfile == 0) {
        Nfile = bb.Nfile;
    }
    if(newfilepath == NULL) {
        newfilepath = argv[1];
    }
    if(0 != big_file_mpi_create(&bfnew, newfilepath, MPI_COMM_WORLD)) {
        fprintf(stderr, "failed to open: %s\n", big_file_get_error_message());
        exit(1);
    }
    if(0 != big_file_mpi_create_block(&bfnew, &bbnew, argv[3], bb.dtype, bb.nmemb, Nfile, bb.size, MPI_COMM_WORLD)) {
        fprintf(stderr, "failed to create temp: %s\n", big_file_get_error_message());
        exit(1);
    }

    if(bbnew.size != bb.size) {
        abort();
    }

    /* copy attrs */
    size_t nattr;
    BigAttr * attrs = big_block_list_attrs(&bb, &nattr);
    int i;
    for(i = 0; i < nattr; i ++) {
        BigAttr * attr = &attrs[i];
        big_block_set_attr(&bbnew, attr->name, attr->data, attr->dtype, attr->nmemb);
    }

    if(bb.nmemb > 0 && bb.size > 0) {
    /* copy data */
        if(ThisTask == 0) {
            server();
        } else {
            slave();
        }
    }
    if(0 != big_block_mpi_close(&bbnew, MPI_COMM_WORLD)) {
        fprintf(stderr, "failed to close new: %s\n", big_file_get_error_message());
        exit(1);
    }
    big_block_mpi_close(&bb, MPI_COMM_WORLD);
    big_file_mpi_close(&bf, MPI_COMM_WORLD);
    big_file_mpi_close(&bfnew, MPI_COMM_WORLD);
    return 0;
}
开发者ID:sbird,项目名称:bigfile,代码行数:87,代码来源:bigfile-copy-mpi.c


示例12: main


//.........这里部分代码省略.........
				if (hp >= &dhosts[NHOSTS-2]) {
					fprintf(stderr, "rdist: too many destination hosts\n");
					exit(1);
				}
				*hp++ = *++argv;
				break;

			case 'd':
				if (--argc <= 0)
					usage();
				define(*++argv);
				break;

			case 'D':
				debug++;
				break;

			case 'c':
				cmdargs++;
				break;

			case 'n':
				if (options & VERIFY) {
					printf("rdist: -n overrides -v\n");
					options &= ~VERIFY;
				}
				nflag++;
				break;

			case 'q':
				qflag++;
				break;

			case 'b':
				options |= COMPARE;
				break;

			case 'R':
				options |= REMOVE;
				break;

			case 'v':
				if (nflag) {
					printf("rdist: -n overrides -v\n");
					break;
				}
				options |= VERIFY;
				break;

			case 'w':
				options |= WHOLE;
				break;

			case 'y':
				options |= YOUNGER;
				break;

			case 'h':
				options |= FOLLOW;
				break;

			case 'i':
				options |= IGNLNKS;
				break;

			default:
				usage();
			}
	}
	*hp = NULL;

	seteuid(userid);
	mktemp(tempfile);

	if (iamremote) {
		server();
		exit(nerrs != 0);
	}

	if (cmdargs)
		docmdargs(argc, argv);
	else {
		if (fin == NULL) {
			if(distfile == NULL) {
				if((fin = fopen("distfile","r")) == NULL)
					fin = fopen("Distfile", "r");
			} else
				fin = fopen(distfile, "r");
			if(fin == NULL) {
				perror(distfile ? distfile : "distfile");
				exit(1);
			}
		}
		yyparse();
		if (nerrs == 0)
			docmds(dhosts, argc, argv);
	}

	exit(nerrs != 0);
}
开发者ID:mihaicarabas,项目名称:dragonfly,代码行数:101,代码来源:main.c


示例13: main

/*===========================================================================

FUNCTION     : main
DEPENDENCIES : None

RETURN VALUE : None

============================================================================*/
int main(int argc, char *argv[])
{
        int pid, cid, status;
        struct sockaddr_rc ra;
        int length, retval = -1;
        char addr[BTADDR_SIZE];
        struct sigaction actions;
        memset(&actions, 0, sizeof(actions));
        sigemptyset(&actions.sa_mask);
        actions.sa_flags = 0;
        actions.sa_handler = abort_handler;

        if (argc != 2) {
                LOGE("Invalid arguements: Usage:  sapd <rfcomm_channel_no>");
                return -1;
        }

        /*Ignore the signals from child to
        prevent becoming zombie*/
        signal(SIGCHLD, SIG_IGN);
        /*Ignore the SIGPIPE signal, this signal will
          emited incase there is an error writing to
          SAP BT App socket */
        signal(SIGPIPE, SIG_IGN);
        if (sigaction(SIGTERM,&actions,NULL) < 0) {
                LOGE("Error in sigaction in %s:  %s\n", __func__, strerror(errno));
                return -1;
        }
        /*Create the pipe between parent and child
        with which all the server side events like
        disconnect,card status event can be communicated
        to child session*/
        if (pipe (server_evt_pipe))
        {
                LOGE ("Pipe Creation failed :%s\n", strerror(errno));
                return -1;
        }

        LOGV("Event pipe created\n");

        while (1) {
                length = sizeof(struct sockaddr_un);
                local_sk = create_server_socket (SAP_SERVER);
                if (local_sk == -1)
                {
                    LOGE("Fatal Error : Could not create Socket for BT SAP:\n");
                    break;
                }

                /*This is the parent daemon, which would keep listening
                for the incoming connections from SAP BT App layer */
                /*Once accepted, It forks a child which takes care of SAP request
                processing, Once the SAP disconnects, parent can accept
                further connections
                */
                conn_sk = accept(local_sk, (struct sockaddr *)&ra, &length);

                LOGV("Accepted incoming connection from SAP BT App");
                if (conn_sk < 0) {
                        close(local_sk);
                        if (errno == EBADF) {
                                LOGE("Invalid local Socket descriptor: %d err: %s\n", local_sk, strerror(errno));
                                /*This signifys that exe is aborted and should be exited*/
                                break;
                        } else {
                                /*remote socket failure case
                                skip the further part, so that SAP server
                                will be back in its wait loop*/
                                LOGE("Invalid local Socket descriptor: %d err: %s\n", local_sk, strerror(errno));
                                continue;
                        }
                }

                /*Process the request in a new child*/
                switch (cid = fork()){
                        case 0:
                                /*In child*/
                                LOGV("In Child process\n");
                                pid = getpid();
                                /*child doesn't need local socket any more*/
                                close(local_sk);
                                /*get SIGHUP on parent's death*/
                                prctl(PR_SET_PDEATHSIG, SIGHUP, 0, 0, 0);
                                /*server will handle the necessary
                                 */
                                LOGV("Starting the server in Child\n");
                                retval = server(conn_sk, server_evt_pipe[0]);
                                /*Exit from child*/
                                LOGV("Exiting from the child\n");
                                exit(0);
                                break;
                        case -1:
//.........这里部分代码省略.........
开发者ID:xingrz,项目名称:android_tools_leeco_msm8996,代码行数:101,代码来源:sap_server.c


示例14: CreateServerNode

int CreateServerNode(int argc, char *argv[]) {
  mshadow::ps::MShadowServerNode<float> server(argc, argv);
  return 0;
}
开发者ID:AI42,项目名称:mshadow,代码行数:4,代码来源:dist_async_sum.cpp


示例15: main

int main (int argc, char * argv[])
{
  Miro::Log::init(argc, argv);
  Miro::Server server(argc, argv);

  // server part
  try {
    std::string name = "AMI";
    XMP::AmiImpl * ami = new XMP::AmiImpl();

    server.activateNamedObject(name, ami);
    server.detach(5);
  }
  catch (CORBA::Exception const& e) {
    MIRO_LOG_OSTR(LL_CRITICAL, "CORBA exception:\n" << e);
  }

  // client part
  try {
    // anything that has a callback is actually a server...
    Miro::Server server(argc, argv);
    XMP::Ami_var ami = server.resolveName<XMP::Ami>("AMI");

    // we just run the ORB in a background thread
    server.detach(3);

    //--------------------------------------------------------------------------
    // calling a method without a return arguement
    {
      //------------------------------------------------------------------------
      // synchronous method call

      std::cout << "synchronous call to s0." << std::endl;
      ami->s0(5);
      std::cout << "s0 returned." << std::endl;
      
      //------------------------------------------------------------------------
      // asynchronous upcall, not caring about the return value
      std::cout << "asynchronous (oneway) call to s." << std::endl;
      ami->sendc_s(NULL);
      std::cout << "s returned." << std::endl;

      //------------------------------------------------------------------------
      // asynchronous call with reply handler

      // the generic AMI helper class
      // instanciated with our generic callback implemenation
      Miro::AmiHelper<XMP::AMI_Ami_s> h;
    
      std::cout << "asynchronous call to s." << std::endl;
      ami->sendc_s(h.handler());
      std::cout << "s returned." << std::endl;
      
      std::cout << "wait for s to finish." << std::endl;
      h.wait();
      // checking return value, in case there was an exception:
      h.rc();
      std::cout << "s finished." << std::endl;


      //------------------------------------------------------------------------
      // asynchronous upcall, not caring about the return value
#ifdef ASDF
      std::cout << "asynchronous (oneway) call to s0." << std::endl;
      ami->sendc_s0(NULL, 4);
      std::cout << "s0 returned." << std::endl;

      //------------------------------------------------------------------------
      // asynchronous call with reply handler

      // the generic AMI helper class
      // instanciated with our generic callback implemenation
      Miro::AmiHelper<XMP::AMI_Ami_s0> h0;
    
      std::cout << "asynchronous call to s0." << std::endl;
      ami->sendc_s0(h0.handler(), 4);
      std::cout << "s0 returned." << std::endl;
      
      std::cout << "wait for s0 to finish." << std::endl;
      h0.wait();
      // checking return value, in case there was an exception:
      h0.rc();
      std::cout << "s0 finished." << std::endl;
#endif
    }
    //--------------------------------------------------------------------------
    // calling a method with one single return arguement
    {
      //------------------------------------------------------------------------
      // synchronous method call

      std::cout << "synchronous call to s1." << std::endl;
      int rc = ami->s1();
      std::cout << "s1 returned:" << rc << std::endl;

      //------------------------------------------------------------------------
      // asynchronous call with reply handler

      // the generic AMI helper class
      Miro::AmiHelper<XMP::AMI_Ami_s1> h1;
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:miro-middleware-svn,代码行数:101,代码来源:ami_colocated_example.cpp


示例16: main

int main(int argc, char **argv) {

	//First we read our arguments from the command line
	while ((c = getopt (argc, argv, "kl:vrw:p:")) != -1)
		switch(c)
		{
			case 'l':
				listenPort = optarg;
				lflag = 1;
				break;
			case 'k':
				kflag = 1;
				break;
			case 'v':
				vflag = 1;
				break;
			case 'w':
				wflag = 1;
				timeOut = atoi(optarg);
				break;
			case 'r':
				rflag = 1;
				break;
			case 'p':
				pflag = 1;
				sourcePort = atoi(optarg);
				break;
			default:
				usage(argv[0]);
				exit(1);
		}

	  //Get hostname and destination port only if -l is not on
	  if (lflag != 1){
		  argn = optind;
		  hostName = argv[argn];
		  //Make sure a port was provided in argv, or we will get a seg fault
		  if(argn+1 >= argc){
		  	usage(argv[0]);
		  	exit(1);
		  } else {
		  	destPort = argv[argn+1];
		  }
		}

	//It is an error to use the -k option without the -l option.
	if(kflag == 1 && lflag == 0){
		usage(argv[0]);
		exit(1);
	}
	
	//It is an error to use the -p option in conjunction with the -l option.
	if (lflag == 1 && pflag ==1){
		usage(argv[0]);
		exit(1);
	}

	//The r option can only be used with the -l option
	if (rflag == 1 && lflag == 0){
		usage(argv[0]);
		exit(1);
	}

	//The w cannot be used with the l option
	if (wflag == 1 && lflag == 1){
		usage(argv[0]);
		exit(1);
	}

    //For debugging
    if(vflag){
	    printf ("kflag = %d, lflag = %d, vflag = %d, wflag= %d, rflag= %d, pflag =%d\n",
		kflag, lflag, vflag, wflag, rflag, pflag);
		printf("The time out is : %d\n", timeOut);
		printf("The sourcePort num is : %d\n", sourcePort);
		printf("The listenPort num is : %s\n", listenPort);
		printf("The hostName num is : %s\n", hostName);
		printf("The destPort num is : %s\n", destPort);
	}

	//Call server() function for -l flag
	if(lflag){
		server(listenPort, kflag);
	}

	//For client
	if(lflag == 0){
		client(hostName, destPort);
	}

    return 0;

}
开发者ID:bollain,项目名称:netClone,代码行数:93,代码来源:ncTh.c


示例17: main


//.........这里部分代码省略.........
    if (strcmp("-src", argv[2]) != 0) {
        print_usage();
        exit(1);
    }
    
    if (strcmp("-d&q 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ serverPanic函数代码示例发布时间:2022-05-30
下一篇:
C++ serve函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap