[omniORB] newbie's question about register_initial_reference()

Duncan Grisby duncan at grisby.org
Fri May 19 13:10:48 BST 2006


On Thursday 18 May, "Luke" wrote:

> Now I have a question, how could I tell the orb which port the servant
> should be listening on so the client could use: client -ORBInitRef
> PingService=corbaloc:iiop:1.2 at host:port/serviceId to find it.
> 
> I now assume it would use the default port 2809. Then the server side
> code is:

No, the server doesn't use the default port of 2809. It uses an
ephemeral port assigned by the operating system. To force the use of a
specific port, you must provide an endPoint configuration parameter. See
section 8.6 of the omniORB manual:

  http://omniorb.sourceforge.net/omni40/omniORB/omniORB008.html#toc41

> CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
>  CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
> PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);
>  INSServer* servant = new INSServer();
> PortableServer::ObjectId_var obj_var = poa->activate_object(servant);
> Service_var serviceRef = server->_this();
> servant->_remove_ref();
> PortableServer::POAManager_var pman = poa->the_POAManager();
> pman->activate();
> orb->register_initial_reference("PingService", serviceRef);
>  orb->run();

You have misunderstood what register_initial_reference is for. It's to
allow callers in the same process to resolve the reference you give --
it has nothing to do with making the reference available to external
clients.

To make your object available for clients to contact with a corbaloc
URI, you must register your object in the special omniINSPOA with a
specific id:

  CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
  CORBA::Object_var obj = orb->resolve_initial_references("omniINSPOA");
  PortableServer::POA_var ins_poa = PortableServer::POA::_narrow(obj);
  INSServer* servant = new INSServer();
  PortableServer::ObjectId_var oid = PortableServer::string_to_ObjectId("PingService")
  ins_poa->activate_object_with_id(oid, servant);

  ... activate the POAManager, etc...


Cheers,

Duncan.

-- 
 -- Duncan Grisby         --
  -- duncan at grisby.org     --
   -- http://www.grisby.org --



More information about the omniORB-list mailing list