[Enterprise Extensions only]
  Previous topic

Creating CORBA client main code (client.cpp), adding code to shutdown the client and release resources used

Use this task to create code for a CORBA client, to shut down the client and release the resources that it used.

This task is one step of the parent task to create the CORBA client main code, as described in Creating a CORBA client main code (client.cpp).

To create code to shut down a CORBA client, edit the client source file, client.cpp to complete the following steps

  1. Add a release_resources method, as shown in the following code extract:
    // This function deallocates resources used throughout the program.
    
    void release_resources( ::CORBA::BOA_ptr bp, ::CORBA::ORB_ptr op )
    {
      // Deallocate the various resources we have allocated.
      ::CORBA::release( bp );
      ::CORBA::release( op );
    }
    

    This method is called at the end of the client's main method after the client has finished accessing the servant object. (You add a call to this method in the next step.) The method takes as input pointers to the BOA and the ORB. It releases the resources used by the client.

  2. Add code to the main method to call the release_resources method (after the client has finished accessing the servant objects), as shown in the following code extract:
      // Deallocate all resources.
      release_resources( bp, op );
    
      cout << endl << "Client COMPLETED" << endl;
      cout.flush();
    
      exit( 0 );
    }
    

This task adds code that shuts down a CORBA client and releases the resources that it used.

  Previous topic