Skip to main content
Skip table of contents

Communicator Initialization and Destruction

Creating a Communicator

You create a communicator by calling Ice::initialize, for example:

RUBY
require 'Ice'

Ice.initialize(ARGV) do |communicator|
    ...
end

Ice,initialize accepts the argument list that is passed to the program by the operating system. The function scans the argument list for any command-line options that are relevant to the Ice runtime; any such options are removed from the argument list so, when Ice.initialize returns, the only options and arguments remaining are those that concern your application. If anything goes wrong during initialization, initialize throws an exception.

This syntax ensures the communicator is destroyed when the block completes. The destroy method is responsible for cleaning up the communicator. In particular, destroy ensures that any outstanding threads started by the underlying Ice C++ communicator are joined with and reclaims a number of operating system resources, such as file descriptors and memory. Never allow your program to terminate without calling destroy first.

The initialize block accepts a single argument, the communicator.

Initialization Data

During the creation of a communicator, initialize configures a number of features that affect the communicator's operation. Once set, these features remain in effect for the lifetime of the communicator, that is, you cannot change these features after you have created a communicator. Therefore, if you want to customize these features, you must do so when you create the communicator.

The InitializationData class or struct holds all the features (or options) that you can customize when you create a communicator.

See Also
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.