TAO Usage Guide - Name Service

xiaoxiao2021-03-06  162

Naming Service, but the name service is a naming service) is one of the most basic services of CORBA. The name service is very simple, there is nothing to say. However, TAO has made an interesting extension on the standard name service, which can take advantage of Ulticast to get the name service. However, individuals believe that in addition to facilitate such a little bit, it is not large. And if there are multiple hosts in the authority network to run the name service at the same time, it will cause confusion.

In addition, TAO also provides NT_naming_service to register the name service as NT service.

I. Start the name service

The file name of the name service is: Naming_Service.exe, its startup parameters are:

% Naming_service [-orbnameserviceport nsport]

[-o ior_output_file]

[-P pid_file_name]

[-s context_size]

[-t time]

[-f persitation_file_name]

[-B base_address]

[-m (1 = enable multicast responses, 0 = disable (default)]

-Orbnameserviceport NSport: Specifies the port number of the Name Service to listen to the Multicast package. It is only valid when '-M 1' is used.

-o iOR_output_file: Specify the file name to save the root of the name service.

-p pid_file_name: Specify file name to save the name service program process ID

-s context_size: When you create a context, specify the size of the hash table used in the new context, the default 1024

-t Time: Time, unit: second. Default: Unlimited

-f persistence_file_name: Specifies the file name to store the object references bound in the name service.

-m (1 = enable multicast responses, 0 = disable (default): Do you use multicast features.

When running the name service, you can use the -orbendpoint parameter to specify the endpoints of its run (see document for -ORBENDPOINT: $ tao_root / docs / orbendpoint.html):

Naming_service -orbendpoint iiop: // localhost: 2809 -m 0

(Name service in this machine's 2809 port monitor request, not using multicast mode)

II. Accessing the name

It is assumed here

Naming_service -orbendpoint iiop: // localhost: 2809 -m 0 To start the name access. There are a variety of ways to access the name service:

the first method:

Use CORBALOC to specify the initial reference with CORBALOC when starting the customer program:

MessengerSerVer -orbinitRef Nameservice = CORBALOC :: Localhost: 2809 / NameService In the MessengerServer source program, use directly:

ORB-> resolve_initial_references ("nameservice");

Come get the name service.

The second method:

Do not use the parameters when the client starts:

Messengerserver

And in the MessengerServer source program, use:

Orb-> string_to_object ("CORBALOC :: Localhost: 2809 / NameService"); to get the name service.

Third. TAO_NAMING_CLIENT and TAO_NAMING_SERVER Class:

1. TAO_NAMING_CLIENT class: The code that accesses the name service section is packaged. How to use:

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

#include tao_naming_client naming_client; if (naming_client.init (orb.in ())! = 0) {CERR << "Could Not Initialize Naming Client." << end1; return 1;} // Analyze

Corba :: Object_var obj = naming_client-> resolve (name);

// Bind

Naming_client-> rebind (Name, Obj_ref.in ());

2. TAO_NAMING_SERVER Class: Use this class, you can integrate the name service function to your own application.

Program.

See how the use of TAO_NAMING_SERVER classes, see: 咦, this routine is not in TAO standard package

Among the OCI's Examples. This forgotten this on my hard drive is downloaded there, if someone needs

I want to write to me.

Four. Name Service Tools

In the $ tao_root / utils directory, there are tools for both NamingViewer and NSList.

If you are interested, you have compiled it. :-)

转载请注明原文地址:https://www.9cbs.com/read-128090.html

New Post(0)