Listing 3: Server initialization

int main(int argc, char **argv)
{
  ...
     // Initialize ORB and obtain a reference to an ORB object.
  1  CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB3");

     // Obtain a reference to a base (root) CORBA object and 
     // activate it. 
     // It is now available to clients.
  2  CORBA::Object_var obj = 
       orb->resolve_initial_references("RootPOA");
  3  PortableServer::POA_var poa = 
       PortableServer::POA::_narrow(obj);

     // Create an instance of the DataReader and activate it.
  4  DataReader* mydata = new DataReader();
  5  PortableServer::ObjectId_var mydataid = 
       poa->activate_object(mydata);

     // Obtain a reference to the object, and register it in
     // the naming service.
  6  obj = mydata->_this();
  7  if( !bindObjectToName(orb, obj, mydata) ) return(1);
  8  mydata->_remove_ref();

     // Increase allowable message size
  9  mydata->drSetServerMessageSize();

     // Active server; its initially in a holding state, 
     // make it active
  10 PortableServer::POAManager_var pman = poa->the_POAManager();
  11 pman->activate();

     // Wait for and processes requests
     cout << "Server running..." << endl;
  12 orb->run();
  ...
}
— End of Listing —