Client.cpp
975 Bytes
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
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//
#include <Ice/Ice.h>
#include <Printer.h>
#include <stdexcept>
using namespace std;
using namespace Demo;
int
main(int argc, char* argv[])
{
try
{
Ice::CommunicatorHolder ich(argc, argv);
auto base = ich->stringToProxy("SimplePrinter1:default -p 10000");
auto printer = Ice::checkedCast<PrinterPrx>(base);
if(!printer)
{
throw std::runtime_error("Invalid proxy");
}
printer->printString("Hello World!");
auto base2 = ich->stringToProxy("SimplePrinter2:default -p 10000");
auto printer2 = Ice::checkedCast<PrinterPrx>(base2);
if(!printer2)
{
throw std::runtime_error("Invalid proxy");
}
printer2->printString("Hello World!");
printer->shutdown();
}
catch(const std::exception& e)
{
cerr << e.what() << endl;
return 1;
}
return 0;
}