#includeint main(int argc, char* argv[]) { try { Ice::CommunicatorPtr communicator = Ice::initialize(argc, argv); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints( "MyAdapter", "tcp -h localhost -p 10000"); adapter->activate(); communicator->waitForShutdown(); } catch(const Ice::Exception& e) { std::cerr << e << std::endl; return 1; } return 0; }
#includeThis example registers a new servant object called "MyServiceI" with the object adapter. The servant implementation must inherit from the generated Ice class for the corresponding interface. The servant is assigned an identity "MyService", which is used to identify it to clients. Once the servant is registered, the adapter is activated and the program waits for a shutdown signal. Package Library: Ice (ZeroC)#include "MyServiceI.h" int main(int argc, char* argv[]) { try { Ice::CommunicatorPtr communicator = Ice::initialize(argc, argv); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints( "MyAdapter", "tcp -h localhost -p 10000"); MyServiceI* servant = new MyServiceI; adapter->add(servant, communicator->stringToIdentity("MyService")); adapter->activate(); communicator->waitForShutdown(); } catch(const Ice::Exception& e) { std::cerr << e << std::endl; return 1; } return 0; }