[omniORB] How to check if server exists ?

Ulf Meyer um@datafactory.de
Fri, 04 Feb 2000 10:15:11 +0100


Adam Dorosz schrieb:

> > In order to check if the omninames server exists, you should set ORBInitialHost and ORBInitialPort parameters in your configuration to the host and port values of omninames.
> > Then you may call resolve_initial_references method of orb to check if the server is active.
> >
>
> But what can I do if resolve_initial_references throws no resources system exception ?
> Is it possible to call ORB_init and resolve_initial_references with another, correct parameters, created at runtime with host name or port number entered by user ? Or I can only
> exit the application with error information and then try to connect again ?
> It all comes from the situation wher host name and port number of  omninames server are not taken from config file, but have to be entered by user of client application.

I used the following code to avoid using the parameters in ORB_init. This also allows me to connect to multiple Name Services in my application:
(using omniORB 2.8.0)
-----------------------------------------------------------------
#include <omniORB\src\lib\omniORB2\bootstrap_i.h>
...
 omniInitialReferences* oir = omniInitialReferences::singleton();
 oir = omniInitialReferences::singleton();
 oir->initialise_bootstrap_agent( m_Hostname, (short) m_Port );
 oir->set("NameService", NULL);

 // contact name service
 try {
  // Obtain a reference to the root context of the Name service:
  CORBA::Object_var initServ;
  initServ = m_ORB->resolve_initial_references("NameService");
...
and so on
---------------------------------------------------------------------
This is, of course, omniORB-specific. The call "oir->set("NameService",NULL)" is needed because omniInitialReferences keeps a map (Servicename -> IOR), so after the NameService IOR
is first obtained via a remote call, all following calls to resolve_initial_references only return this first IOR. If you change the Hostname/Port configuration, the above call
forces omniInitalReferences to get a "new" NameService IOR via remote call with the new host/port configuration.

Ulf
--

datafactory - Gesellschaft fuer Informationssysteme mbH
Stoehrerstr. 17                   Tel. +49(341)24495- 0
04347 Leipzig                     Fax. +49(341)24495-25
http://www.datafactory.de      mailto:um@datafactory.de