i got a question about naming service
- From: <folke sina com cn>
- To: <orbit-list gnome org>
- Subject: i got a question about naming service
- Date: Wed, 25 Dec 2002 15:47:25 +0800
#include "RouterDriver-skelimpl.c"
#include "ORBitservices/CosNaming.h"
#include <string.h>
#include <stdio.h>
int
main(int argc, char* argv[])
{
CORBA_ORB orb;
CORBA_Environment* ev;
PortableServer_ObjectId* oid;
Router_Driver obj_routerDriver;
PortableServer_POA root_poa;
PortableServer_POAManager pm;
FILE *fd_iorFile = NULL;
char ac_iorBuf[1024] = {'\0'};
CORBA_Object nameServer;
CosNaming_NameComponent name_component[3] = { {"Linux", "subcontext"},
{"Server", "subcontext"},
{"Driver", "server"} };
CosNaming_Name name = {3, 3, name_component, CORBA_FALSE};
gchar* dummy_argv[2];
gint dummy_argc;
ev = g_new0(CORBA_Environment,1);
CORBA_exception_init(ev);
orb = CORBA_ORB_init(&argc, argv, "orbit-local-orb", ev);
root_poa = (PortableServer_POA)CORBA_ORB_resolve_initial_references(orb, "RootPOA", ev);
obj_routerDriver = impl_Router_Driver__create(root_poa, ev);
// impl_Router_Driver__create() is a function defined in my RouterDriver-stubs.c
fd_iorFile = fopen("nameservice.ior", "r");
if (fd_iorFile == NULL){
printf("failed to register service!\n");
exit(-1);
}
fgets(ac_iorBuf, 1024, fd_iorFile);
if (ac_iorBuf[strlen(ac_iorBuf)-1] == '\n'){
ac_iorBuf[strlen(ac_iorBuf)-1] = '\0';
}
fclose(fd_iorFile);
nameServer = CORBA_ORB_string_to_object(orb, ac_iorBuf, ev);
if (ev->_major != CORBA_NO_EXCEPTION) {
fprintf (stderr, "Error: could not get name service: %s\n", CORBA_exception_id(ev));
exit (-1);
}
CosNaming_NamingContext_bind(nameServer, &name, obj_routerDriver, ev);
if (ev->_major != CORBA_NO_EXCEPTION) {
fprintf (stderr, "Error: could register object: %s\n", CORBA_exception_id(ev));
exit (-1);
}
pm = PortableServer_POA__get_the_POAManager(root_poa, ev);
PortableServer_POAManager_activate(pm, ev);
CORBA_ORB_run(orb, ev);
return 0;
}
i build the server and run it,
it exits with
Error: could register object: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0
i am not sure whether i followed the correct procedure of calling a name service,
so i wonder how can i fix this problem.
thanks in advance
folke
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]