Fork me on GitHub

Network Your Software

Trusted by Industry Leaders

Ice

A Comprehensive RPC Framework

Flexible

Make synchronous and asynchronous invocations using TCP, UDP, SSL/TLS, and WebSockets. Bidirectional connections allow a server to reuse a connection established by a client to make callbacks.

Secure

Ice offers powerful and easy to use security features. The IceSSL plug-in uses your operating system's SSL/TLS stack to encrypt your data and authenticate your connections.

Fast

Ice uses a compact, efficient binary protocol to minimize CPU and bandwidth consumption.

Everywhere

Develop in C++, C#, Java, JavaScript, Objective-C, PHP, Python, and Ruby. Deploy on Linux, OS X, Windows, Android, and iOS.

An Introduction to

Ice

Slice - Ice's Interface Definition Language

// Printer.ice
module Demo {
    interface Printer {
        //
        // A client can invoke this operation on a server.
        // In this example we print the string s
        //
        void printString(string s);
    };
};

Compile Slice to C++, C#, Java, ...

# compile Slice               # generated files
slice2cpp  Printer.ice        # Printer.h, Printer.cpp
slice2cs   Printer.ice        # Printer.cs
slice2java Printer.ice        # Demo/Printer.java, Demo/...
slice2js   Printer.ice        # Printer.js
slice2objc Printer.ice        # Printer.h, Printer.m
slice2php  Printer.ice        # Printer.php
slice2py   Printer.ice        # Printer.py
slice2rb   Printer.ice        # Printer.rb

Implement Printer Interface in C++

class PrinterI : public Demo::Printer {
public:
    virtual void printString(const string& s, const Ice::Current&) {
        cout << s << endl;
    }
};

Write your server in C++

// Initialize Ice communicator - used for interacting with the Ice runtime
Ice::CommunicatorPtr communicator = Ice::initialize(argc, argv);

// Instantiate a new PrinterI servant - the implementation of your Printer
Ice::ObjectPtr object = new PrinterI;

// Create object adapter - a container for your servants. Listens on port 10000
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("SimplePrinterAdapter", "tcp -p 10000");

// Add the servant object to the object adapter with identity "SimplePrinter"
adapter->add(object, communicator->stringToIdentity("SimplePrinter"));

// Activate object adapter - accept incoming requests and dispatch them to servants
adapter->activate();

Implement Printer Interface in C#

public class PrinterI : Demo.PrinterDisp_
{
    public override void printString(string s, Ice.Current current)
    {
        Console.WriteLine(s);
    }
}

Write your server in C#

// Initialize Ice communicator - used for interacting with the Ice runtime
Ice.Communicator communicator = Ice.Util.initialize(ref args);

// Instantiate a new PrinterI servant - the implementation of your Printer
Ice.Object object = new PrinterI();

// Create object adapter - a container for your servants. Listens on port 10000
Ice.ObjectAdapter adapter = communicator.createObjectAdapterWithEndpoints("SimplePrinterAdapter", "tcp -p 10000");

// Add the servant object to the object adapter with identity "SimplePrinter"
adapter.add(object, communicator.stringToIdentity("SimplePrinter"));

// Activate object adapter - accept incoming requests and dispatch them to servants
adapter.activate();

Implement Printer Interface in Java

@Override public class PrinterI extends Demo._PrinterDisp {
    public void printString(String s, Ice.Current current)
    {
        System.out.println(s);
    }
}

Write your server in Java

// Initialize Ice communicator - used for interacting with the Ice runtime
Ice.Communicator communicator = Ice.Util.initialize(args);

// Instantiate a new PrinterI servant - the implementation of your Printer
Ice.Object object = new PrinterI();

// Create object adapter - a container for your servants. Listens on port 10000
Ice.ObjectAdapter adapter = communicator.createObjectAdapterWithEndpoints("SimplePrinterAdapter", "tcp -p 10000");

// Add the servant object to the object adapter with identity "SimplePrinter"
adapter.add(object, communicator.stringToIdentity("SimplePrinter"));

// Activate object adapter - accept incoming requests and dispatch them to servants
adapter.activate();

Implement Printer Interface in Objective-C

@interface PrinterI : DemoPrinter
@end

@implementation PrinterI
-(void) printString:(NSMutableString*)s current:(ICECurrent*)current
{
    printf("%s\n", [s UTF8String]);
}
@end

Write your server in Objective-C

// Initialize Ice communicator - used for interacting with the Ice runtime
id communicator = communicator = [ICEUtil createCommunicator:&argc argv:argv];

// Instantiate a new PrinterI servant - the implementation of your Printer
ICEObject *object = [[[PrinterI alloc] init] autorelease];

// Create object adapter - a container for your servants. Listens on port 10000
id adapter = [communicator createObjectAdapterWithEndpoints: @"SimplePrinterAdapter"
                                                  endpoints: @"tcp -p 10000"];

// Add the servant object to the object adapter with identity "SimplePrinter"
[adapter add:object identity:[communicator stringToIdentity:@"SimplePrinter"]];

// Activate object adapter - accept incoming requests and dispatch them to servants
[adapter activate];

Implement Printer Interface in Python

class PrinterI(Demo.Printer):
    def printString(self, s, current=None):
        print(s)

Write your server in Python

# Initialize Ice communicator - used for interacting with the Ice runtime
communicator = Ice.initialize(sys.argv)

# Instantiate a new PrinterI servant - the implementation of your Printer
object = PrinterI()

# Create object adapter - a container for your servants. Listens on port 10000
adapter = communicator.createObjectAdapterWithEndpoints("SimplePrinterAdapter", "tcp -p 10000")

# Add the servant object to the object adapter with identity "SimplePrinter"
adapter.add(object, communicator.stringToIdentity("SimplePrinter"))

# Activate object adapter - accept incoming requests and dispatch them to servants
adapter.activate()

Say Hello using Ice for C++

// Initialize Ice communicator - used for interacting with the Ice runtime
Ice::CommunicatorPtr communicator = Ice::initialize(argc, argv);

// Create a proxy to the remote Printer object
Ice::ObjectPrx obj = communicator->stringToProxy("SimplePrinter:tcp -h serverhost.serverdomain -p 10000");

// Downcast obj to Printer proxy
Demo::PrinterPrx printer = Demo::PrinterPrx::checkedCast(obj);

// Invoke "printString" operation on remote Printer object
printer->printString("Hello World!");

Say Hello using Ice for C#

// Initialize Ice communicator - used for interacting with the Ice runtime
Ice.Communicator communicator = Ice.Util.initialize(ref args);

// Create a proxy to the remote Printer object
Ice.ObjectPrx obj = communicator.stringToProxy("SimplePrinter:tcp -h serverhost.serverdomain -p 10000");

// Downcast obj to Printer proxy
Demo.PrinterPrx printer = Demo.PrinterPrxHelper.checkedCast(obj);

// Invoke "printString" operation on remote Printer object
printer.printString("Hello World!");

Say Hello using Ice for Java

// Initialize Ice communicator - used for interacting with the Ice runtime
Ice.Communicator communicator = Ice.Util.initialize(args);

// Create a proxy to the remote Printer object
Ice.ObjectPrx obj = communicator.stringToProxy("SimplePrinter:tcp -h serverhost.serverdomain -p 10000");

// Downcast obj to Printer proxy
Demo.PrinterPrx printer = Demo.PrinterPrxHelper.checkedCast(obj);

// Invoke "printString" operation on remote Printer object
printer.printString("Hello World!");

Say Hello using Ice for Objective-C

// Initialize Ice communicator - used for interacting with the Ice runtime
id communicator = [ICEUtil createCommunicator:&argc argv:argv];

// Create a proxy to the remote Printer object
id obj = [communicator stringToProxy:@"SimplePrinter:tcp -h serverhost.serverdomain -p 10000"];

// Downcast obj to Printer proxy
id printer = [DemoPrinterPrx checkedCast:obj];

// Invoke "printString" operation on remote Printer object
[printer printString:@"Hello World!"];

Say Hello using Ice for Python

# Initialize Ice communicator - used for interacting with the Ice runtime
communicator = Ice.initialize(sys.argv)

# Create a proxy to the remote Printer object
obj = communicator.stringToProxy("SimplePrinter:tcp -h serverhost.serverdomain -p 10000")

# Downcast obj to Printer proxy
printer = Demo.PrinterPrx.checkedCast(obj)

# Invoke "printString" operation on remote Printer object
printer.printString("Hello World!")

Say Hello using Ice for JavaScript

// Initialize Ice communicator - used for interacting with the Ice runtime
var communicator = Ice.initialize();

// Create a proxy to the remote Printer object
var obj = communicator.stringToProxy("SimplePrinter:tcp -h serverhost.serverdomain -p 10000");

// Downcast obj to Printer proxy
Demo.PrinterPrx.checkedCast(obj).then(function(printer) {

    // Invoke "printString" operation on remote Printer object
    return printer.printString("Hello World!");
});

Say Hello using Ice for PHP

// Initialize Ice communicator - used for interacting with the Ice runtime
$communicator = Ice_initialize();

// Create a proxy to the remote Printer object
$obj = $communicator->stringToProxy("SimplePrinter:tcp -h serverhost.serverdomain -p 10000");

// Downcast obj to Printer proxy
$printer = Demo_PrinterPrxHelper::checkedCast($obj);

// Invoke "printString" operation on remote Printer object
$printer->printString("Hello World!");

Say Hello using Ice for Ruby

# Initialize Ice communicator - used for interacting with the Ice runtime
communicator = Ice::initialize(ARGV)

# Create a proxy to the remote Printer object
obj = communicator.stringToProxy("SimplePrinter:tcp -h serverhost.serverdomain -p 10000")

# Downcast obj to Printer proxy
printer = Demo::PrinterPrx::checkedCast(obj)

# Invoke "printString" operation on remote Printer object
printer.printString("Hello World!")

Language Mappings

Ice for C++Ice for C#Ice for JavaIce for JavaScriptIce for Objective-CIce for PHPIce for PythonIce for Ruby

Ice Services

Ice is more than a RPC framework. It also provides a number of complementary services for your networked applications.

IceGrid

Deployment and Monitoring

Glacier2

Firewall Traversal

IceStorm

Event Publish/Subscribe

Freeze &
FreezeScript

Persistent Object Storage

IcePatch2

File Distribution and Patching

Get Started with Ice

Whether you're working on an enterprise application or hobbyist project, Ice makes it easy to network your software.

Download Ice  Documentation

Need help? Join our forums.