#includeint main(int argc, char* argv[]) { Ice::CommunicatorPtr communicator; try { communicator = Ice::initialize(argc, argv); // Use communicator to make calls to server } catch (const Ice::Exception& e) { std::cerr << e << std::endl; return 1; } return 0; }
#includeHere, we define a class that inherits from the Ice::Application class and overrides its run method. This method creates a new object adapter, adds a new service to it, activates the adapter, and then waits for the server to shut down. We then create a new instance of the MyServer class and call its main method, which starts the server. The package library for CPP ICE is IceStorm.class MyServer : public Ice::Application { public: virtual int run(int argc, char* argv[]) override { auto adapter = communicator()->createObjectAdapter("MyAdapter"); adapter->add(new MyServiceI, communicator()->stringToIdentity("MyService")); adapter->activate(); communicator()->waitForShutdown(); return 0; } }; int main(int argc, char* argv[]) { MyServer server; server.main(argc, argv); }