Hier ist noch ein Beispiel, wie man in C++ beim Mico ORB
die IOR aus der Datei verarbeitet. Die Funktionen gehören
zum Standard und funktionieren auch bei anderen ORB's.
Am besten den ORB herunterladen und dann viel lesen.
Für den Naming Service könnte ich auch Beispiel liefern, wenn
ich Zeit habe.
Das Beispiel ist aus der Hilfe des Mico.
|
C Quellcode
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#include "hello.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef _WIN32
#include <direct.h>
#endif
using namespace std;
int
main (int argc, char *argv[])
{
CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
/*
* IOR is in hello.ref in the local directory
*/
char pwd[256], uri[300];
sprintf (uri, "file://%s/hello.ref", getcwd(pwd, 256));
/*
* Bind to Hello World server
*/
CORBA::Object_var obj = orb->string_to_object (uri);
HelloWorld_var hello = HelloWorld::_narrow (obj);
if (CORBA::is_nil (hello)) {
printf ("oops: could not locate HelloWorld server\n");
exit (1);
}
hello->hello ();
// sleep(1);
// hello->hello();
return 0;
}
|