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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
#include <stdio.h>
#include <orb/orbit.h>
#include "echo.h"
Echo echo_client, bec;
int
main (int argc, char *argv[])
{
CORBA_Environment ev;
CORBA_ORB orb;
CORBA_long rv;
char buf[30];
int i;
CORBA_exception_init(&ev);
orb = CORBA_ORB_init(&argc, argv, "mico-local-orb", &ev);
if(argc < 2)
{
printf("Need a binding ID thing as argv[1]\n");
return 1;
}
/*
* MICO stuff
*/
echo_client = CORBA_ORB_string_to_object(orb, argv[1], &ev);
if (!echo_client) {
printf("Cannot bind to %s\n", argv[1]);
return 1;
}
for(i = 0; i < 100; i++) {
g_snprintf(buf, sizeof(buf), "Hello, world [%d]", i);
bec = Echo_echoString(echo_client, buf, &rv, &ev);
if(ev._major != CORBA_NO_EXCEPTION) {
printf("we got exception %d from echoString!\n", ev._major);
return 1;
}
g_assert(echo_client == bec);
CORBA_Object_release(echo_client, &ev);
if(ev._major != CORBA_NO_EXCEPTION) {
printf("we got exception %d from release!\n", ev._major);
return 1;
} else
g_message("[client] %d", rv);
echo_client = bec; bec = CORBA_OBJECT_NIL;
}
CORBA_Object_release(echo_client, &ev);
CORBA_Object_release((CORBA_Object)orb, &ev);
return 0;
}
|