Home Help Center

Differences between callback and bidir sample

teoMaloteoMalo Member Matteo MalosioOrganization: Institute of Industrial Technology and AutomationProject: Prototype for robotic upper limb rehabilitation
I can't deeply understand the difference between the callback and the bidir examples.
In the first the client sends the server a proxy to itself, in the second sends its identity.
Storing the proxy in a member variable of the server class and calling client class methods through this variable isn't the same, in terms of functionality, of calling client methods after having received the client identity?

Thank you


  • matthewmatthew NL, CanadaMember Matthew NewhookOrganization: ZeroC, Inc.Project: Internet Communications Engine ✭✭✭
    The bidir example uses a bi-directional connection for its callback. This means that the server calls back on the client over the connection that the client established to the server. In the callback demo, the server would instead establish a new connection to the client for the callback.

    bi-direction connections are useful if the client may not be directly reachable by the server. For example, if the client is behind a firewall or through a NAT router this will be the case.

    To be specific, in the bidir demo you can see the following:
    CallbackSenderI::addClient(const Identity& ident, const Current& current)
        IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
        cout << "adding client `" << _communicator->identityToString(ident) << "'"<< endl;
        CallbackReceiverPrx client = CallbackReceiverPrx::uncheckedCast(current.con->createProxy(ident));

    createProxy returns a proxy which is bound to a specific connection. All invocations on that proxy only go over that connection. You can find more details in the Ice manual.
Sign In or Register to comment.