Merge pull request #1551 from DOCGroup/plm_jira_333
[ACE_TAO.git] / TAO / orbsvcs / examples / ORT / client.cpp
blobef121f691799426c1e05e7eac99da9ab1c19915a
1 // -*- C++ -*-
2 #include "sum_serverC.h"
3 #include "ace/Get_Opt.h"
5 const ACE_TCHAR *ior = ACE_TEXT("file://test.ior");
7 int
8 parse_args (int argc, ACE_TCHAR *argv[])
10 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:"));
11 int c;
13 while ((c = get_opts ()) != -1)
14 switch (c)
16 case 'k':
17 ior = get_opts.optarg;
18 break;
19 default:
20 ACE_ERROR_RETURN ((LM_ERROR,
21 "Usage: %s "
22 "-k IOR "
23 "\n",
24 argv[0]),
25 -1);
27 return 0;
30 int
31 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
33 try
35 CORBA::ORB_var orb =
36 CORBA::ORB_init (argc, argv, "client_sum_orb");
38 if (parse_args (argc, argv) != 0)
39 return 1;
41 CORBA::Object_var obj =
42 orb->string_to_object (ior);
44 ORT::sum_server_var server =
45 ORT::sum_server::_narrow (obj.in ());
47 if (CORBA::is_nil (server.in ()))
49 ACE_ERROR_RETURN ((LM_ERROR,
50 "Object reference <%s> is nil.\n",
51 ior),
52 1);
55 CORBA::ULong a = 5;
56 CORBA::ULong b = 3;
58 CORBA::ULong result = server->add_variables (a,
59 b);
61 if (result != 8)
62 ACE_DEBUG ((LM_DEBUG,
63 "Error: Add Variables did not return the right value\n"));
65 catch (const CORBA::Exception& ex)
67 ex._tao_print_exception ("ORT example on client side :");
68 return -1;
71 return 0;