1,2d0 < // server.cpp,v 1.6 2003/11/01 11:15:11 dhinton Exp < 5a4,9 > #include > #include > #include > #include > #include > #include 7,9d10 < ACE_RCSID (Hello, < server, < "server.cpp,v 1.6 2003/11/01 11:15:11 dhinton Exp") 11a13 > bool increment_endpoint_port = false; 16c18 < ACE_Get_Opt get_opts (argc, argv, "o:"); --- > ACE_Get_Opt get_opts (argc, argv, "io:"); 25a28,31 > case 'i': > increment_endpoint_port = true; > break; > 30a37 > "-i" 44,64d50 < CORBA::ORB_var orb = < CORBA::ORB_init (argc, argv, "" ACE_ENV_ARG_PARAMETER); < ACE_TRY_CHECK; < < CORBA::Object_var poa_object = < orb->resolve_initial_references("RootPOA" ACE_ENV_ARG_PARAMETER); < ACE_TRY_CHECK; < < PortableServer::POA_var root_poa = < PortableServer::POA::_narrow (poa_object.in () ACE_ENV_ARG_PARAMETER); < ACE_TRY_CHECK; < < if (CORBA::is_nil (root_poa.in ())) < ACE_ERROR_RETURN ((LM_ERROR, < " (%P|%t) Panic: nil RootPOA\n"), < 1); < < PortableServer::POAManager_var poa_manager = < root_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); < ACE_TRY_CHECK; < 68,87c54,113 < Hello *hello_impl; < ACE_NEW_RETURN (hello_impl, < Hello (orb.in ()), < 1); < PortableServer::ServantBase_var owner_transfer(hello_impl); < < Test::Hello_var hello = < hello_impl->_this (ACE_ENV_SINGLE_ARG_PARAMETER); < ACE_TRY_CHECK; < < CORBA::String_var ior = < orb->object_to_string (hello.in () ACE_ENV_ARG_PARAMETER); < ACE_TRY_CHECK; < < // Output the IOR to the < FILE *output_file= ACE_OS::fopen (ior_output_file, "w"); < if (output_file == 0) < ACE_ERROR_RETURN ((LM_ERROR, < "Cannot open output file for writing IOR: %s", < ior_output_file), --- > const int numRuns( 3 ); > int run( 1 ); > bool runAgain( true ); > int port( 50000 ); > > do > { > ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - starting a run\n")); > > std::stringstream endpoint; > if (increment_endpoint_port) > port++; > endpoint << "iiop://localhost:" << port; > char *orbArgv[] = { > "-ORBlistenEndpoints", > CORBA::string_dup(endpoint.str().c_str()) > }; > int orbArgc (sizeof(orbArgv) / sizeof (char *)); > > CORBA::ORB_var orb = > CORBA::ORB_init (orbArgc, orbArgv, "" ACE_ENV_ARG_PARAMETER); > ACE_TRY_CHECK; > > CORBA::Object_var poa_object = > orb->resolve_initial_references("RootPOA" ACE_ENV_ARG_PARAMETER); > ACE_TRY_CHECK; > > PortableServer::POA_var root_poa = > PortableServer::POA::_narrow (poa_object.in () ACE_ENV_ARG_PARAMETER); > ACE_TRY_CHECK; > > if (CORBA::is_nil (root_poa.in ())) > ACE_ERROR_RETURN ((LM_ERROR, > " (%P|%t) Panic: nil RootPOA\n"), > 1); > > PortableServer::POAManager_var poa_manager = > root_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); > ACE_TRY_CHECK; > > Hello *hello_impl; > ACE_NEW_RETURN (hello_impl, > Hello (orb.in ()), > 1); > PortableServer::ServantBase_var owner_transfer(hello_impl); > > Test::Hello_var hello = > hello_impl->_this (ACE_ENV_SINGLE_ARG_PARAMETER); > ACE_TRY_CHECK; > > CORBA::String_var ior = > orb->object_to_string (hello.in () ACE_ENV_ARG_PARAMETER); > ACE_TRY_CHECK; > > // Output the IOR to the > FILE *output_file= ACE_OS::fopen (ior_output_file, "w"); > if (output_file == 0) > ACE_ERROR_RETURN ((LM_ERROR, > "Cannot open output file for writing IOR: %s", > ior_output_file), 89,90c115,119 < ACE_OS::fprintf (output_file, "%s", ior.in ()); < ACE_OS::fclose (output_file); --- > ACE_OS::fprintf (output_file, "%s", ior.in ()); > ACE_OS::fclose (output_file); > > poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); > ACE_TRY_CHECK; 92,93c121,122 < poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); < ACE_TRY_CHECK; --- > orb->run (ACE_ENV_SINGLE_ARG_PARAMETER); > ACE_TRY_CHECK; 95,96c124,133 < orb->run (ACE_ENV_SINGLE_ARG_PARAMETER); < ACE_TRY_CHECK; --- > if (run < numRuns) > { > ++run; > ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop restarting\n")); > } > else > { > ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n")); > runAgain = false; > } 98c135,136 < ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n")); --- > root_poa->destroy (1, 1 ACE_ENV_ARG_PARAMETER); > ACE_TRY_CHECK; 100,101c138,139 < root_poa->destroy (1, 1 ACE_ENV_ARG_PARAMETER); < ACE_TRY_CHECK; --- > orb->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); > ACE_TRY_CHECK; 103,104c141 < orb->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); < ACE_TRY_CHECK; --- > } while (runAgain);