Results 1 to 5 of 5

Thread: Making C++ throughput demo oneway?

  1. #1
    SteveWampler is offline Registered User
    Join Date
    Sep 2003
    Posts
    48

    Making C++ throughput demo oneway?

    Ice-1.1.1:

    To help me learn about Ice I thought I'd try adapting the Ice/demo/throughput
    clients (C++ and Java) to use oneway messaging instead of twoway. I had
    no problems with the Java version, but when I try to run my modified
    Client.cpp I get:

    sending and receiving 1 sequences of size 4096 (this may take a while)
    BasicStream.cpp:464: Ice::UnmarshalOutOfBoundsException:
    protocol error: out of bounds during unmarshaling

    (I've also modified the program to accept repetitions and seqSize as
    command line arguments, hence the change in the above message. This
    code works fine in the twoway case.)

    I built the oneway example following the example given in 16.10 of the
    manual - the key code segment in the modified Client.cpp is:

    Ice::ObjectPrx base = communicator->stringToProxy(proxy);
    Ice::ObjectPrx oneway;
    try {
    oneway = base->ice_oneway();
    }
    catch (...) { // Couldn't compile with (const Ice::NoEndPointException &) per example?
    cerr << "No endpoint for oneway invocations" << endl;
    return EXIT_FAILURE;
    }
    ThroughputPrx throughput = ThroughputPrx::uncheckedCast(oneway);
    if(!throughput)
    {
    cerr << argv[0] << ": invalid proxy" << endl;
    return EXIT_FAILURE;
    }

    This compiles and builds, but dies on the later:

    throughput->echoByteSeq(seq);

    with the above message.

    Can someone point me to what I've done wrong?

    Thanks!

  2. #2
    mes's Avatar
    mes
    mes is offline ZeroC Staff
    Name: Mark Spruiell
    Organization: ZeroC, Inc.
    Project: Ice Developer
    Join Date
    Feb 2003
    Location
    California
    Posts
    1,441
    Hi Steve,

    The most common reason for an UnmarshalOutOfBoundsException is invoking a twoway operation using a oneway proxy. The echoByteSeq operation cannot be invoked using a oneway proxy because it does not conform to oneway semantics; specifically, it has a non-void return value. The client-side run-time attempts to unmarshal the return value, which of course is not available when the operation is invoked with a oneway proxy.

    You should change your code to invoke sendByteSeq instead.

    Also, thanks for finding an error in the manual: the exception name should be Ice::NoEndpointException.

    - Mark

  3. #3
    michi's Avatar
    michi is offline Registered User
    Name: Michi Henning
    Organization: Triodia Technologies
    Project: I have a passing interest in Ice :-)
    Join Date
    Feb 2003
    Location
    Brisbane, Australia
    Posts
    1,055

    Re: Making C++ throughput demo oneway?

    Originally posted by SteveWampler
    Ice-1.1.1:

    but when I try to run my modified
    Client.cpp I get:

    sending and receiving 1 sequences of size 4096 (this may take a while)
    BasicStream.cpp:464: Ice::UnmarshalOutOfBoundsException:
    protocol error: out of bounds during unmarshaling

    [...]

    This compiles and builds, but dies on the later:

    throughput->echoByteSeq(seq);

    with the above message.

    Can someone point me to what I've done wrong?

    Thanks!
    Hi Steve,

    the error you are seeing is caused by trying to invoke an operation that returns a result via a oneway proxy. For oneway invocations, the operation must have a void return type, must not have any out parameters, and must not have an exception specification.

    The doc currently states that, in this case, you should get a TwowayOnlyException, but that isn't implemented in Ice 1.1.1 yet. I'm about to add this, so it will work as intended in Ice 1.2.

    The solution is not to call echoByteSeq() but sendByteSeq(). That operation doesn't return anything and can therefore be invoked via a oneway proxy.

    You will see the same error if you down-cast a oneway proxy from Object to its actual type using a checkedCast, because a checkedCast requires sending a message to the server and receiving a reply. So, to down-cast oneway proxies, you must always use an uncheckedCast.

    Cheers,

    Michi.

  4. #4
    michi's Avatar
    michi is offline Registered User
    Name: Michi Henning
    Organization: Triodia Technologies
    Project: I have a passing interest in Ice :-)
    Join Date
    Feb 2003
    Location
    Brisbane, Australia
    Posts
    1,055
    Originally posted by mes
    Hi Steve,

    Also, thanks for finding an error in the manual: the exception name should be Ice::NoEndpointException.

    - Mark
    Ah yes! I'll fix that for next version.

    Cheers,

    Michi.

  5. #5
    SteveWampler is offline Registered User
    Join Date
    Sep 2003
    Posts
    48
    Thanks - sendByteSeq() works like a charm!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 3
    Last Post: 06-06-2007, 05:57 PM
  2. Making Ice objects Java Serializable
    By blair in forum Help Center
    Replies: 1
    Last Post: 03-13-2007, 06:40 PM
  3. Replies: 7
    Last Post: 07-05-2006, 03:46 AM
  4. Problem making a clinet with IceE
    By cesartovic in forum Help Center
    Replies: 2
    Last Post: 02-16-2006, 10:23 AM
  5. Making NIO easier for ICE
    By rdilipk in forum Comments
    Replies: 2
    Last Post: 04-28-2004, 04:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •