Home Help Center

determine messagesize during runtime

DeepDiverDeepDiver Member Thomas MuellerOrganization: Freelance Software DeveloperProject: Project depend on Customers ✭✭✭
hi,

is there any way to calculate the message size of a method invokation?

scenario:
i have a sequence or dictionary which shall be transmitted to the server.
in case the sequence is too long - i need to splitt the sequence and
perform multiple invokations.

but: what is the max length/count of the sequence/dictionary?

i can do it with an try and error approach to find out, but calculating it
during runtime would really be nice.

thx & cu tom

Comments

  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi Tom,

    You could use the streaming API: you create an output stream, write the data to the output stream and get the size of the resulting byte sequence. Note that this is a bit expensive however because you'll need to marshall twice the data (unless you send the byte sequence directly and use the streaming API on the receiving side to umarshall the data). And to be exact, you'll also need to take into account the size of the Ice message and request header (see Chapter 33.3 in the Ice Manual).

    The Chapter 35 in the Ice manual documents how to use the streaming API and you'll also find a demo in demo/Ice/invoke.

    Cheers,
    Benoit.
  • DeepDiverDeepDiver Member Thomas MuellerOrganization: Freelance Software DeveloperProject: Project depend on Customers ✭✭✭
    Hi Benoit,

    thanks for the hint!
    Marshall twice doesn't sound very good to tell the truth.

    What about making the compiler to add message size calculation routines
    to the generated types?
    This way we atleast know the sizes of method parameters.

    Getting the size of message and request headers shouldn't be so
    complicated - the proxy/connection could give us this info.

    Well - just an idea!

    CU Tom
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi Tom,

    It would work for sequences or dictionaries with fixed size types but for variable size types, you would still need to go through the whole sequence or dictionnary to figure out its size.

    Also, if you're using only fixed size types, you only need to marshall once a sequence/dictionary element with the streaming API to figure out its size.

    Cheers,
    Benoit.
Sign In or Register to comment.