[omniORB] Two Servers, One Client

Duncan Grisby duncan at grisby.org
Sun Nov 16 21:06:11 GMT 2003


On Wednesday 12 November, Johan Cronje wrote:

> I have a single servant implementation that I want to run on two computers.
> I have a client that must communicate with both these servants, using the 
> Naming service to obtain object references.

OK. That's a common thing to do.

> I have set up my nameservice as follows:
> On one machine, I have my servant bound to the root context as follows:
[...]

Perfectly sensible. You have given your two objects two names in the
naming service.

[...]
> My relevant client code is:
> 
> sdr_corba_helper help_me; // class that contains get_obj_ref() method

You haven't told us what get_obj_ref does.

> const char* options[] [2] =  
> {{"InitRef","NameService=corbaname::michelle.dsp.sun.ac.za:"},
>  {"InitRef","NameService=corbaname::fee.dsp.sun.ac.za:"},
>  {0,0}};  // setup nameservice

This is a mistake. You should only be running one naming service. You
should therefore only give a reference to one of them in the InitRef
configuration. Even if you _did_ want to have two naming services
(which you most definitely don't), you can't give them both the
initial reference name "NameService". You would have to pick different
names.

[...]
> What am I doing wrong? Is this the correct way to identify the
> wanted servant if it runs on two or more machines? Also, if I use
> the options array as above, does it override or complement the setup
> in omniORB.cfg?

Setting the options as you have overrides omniORB.cfg.

You seem to be trying to make life much harder for yourself than it
needs to be. The naming service is a very simple directory mapping
names to object references. You simply need to look up the two names
for your two objects. Something like this (untested) code that uses
corbaname URIs will do it...

  CORBA::Object_var obj;
  MyObjectType_var ref1, ref2;  // This is the type of your object

  obj = orb->string_to_object("corbaname:rir:#subcontroller.sdr/jjc.michelle");
  ref1 = MyObjectType::_narrow(obj);

  obj = orb->string_to_object("corbaname:rir:#subcontroller.sdr/jjc.fee");
  ref2 = MyObjectType::_narrow(obj);

Cheers,

Duncan.

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



More information about the omniORB-list mailing list