• [basic question] octet type

    From Oliver Kellogg@21:1/5 to Michi Henning on Thu May 28 12:37:33 2020
    These problems go away with the IDL v4 added types int8_t and uint8_t which have precise defined ranges.
    They should be preferred over octet when possible.

    - Oliver


    On Friday, April 21, 2000 at 9:00:00 AM UTC+2, Michi Henning wrote:
    On Thu, 20 Apr 2000, Bruno Robin wrote:

    'OMG IDL Syntax and Semantics' says : 'The octet type is an 8-bit
    quantity that is guaranteed not to undergo any conversion when
    transmitted by the communication system'.

    Does it mean that octet type is only suitable for representing data like bit string for example ? If I want to pass integer values in the range [-128..+127], can I safely use an octet type or have I to use a short
    type ? Same question if my integer values are only in the range
    [0..+127] ?

    Strictly speaking, you will have to use a short. If you don't mind living
    a risky life, you can use octet. Basically, an octet is a blob of eight uninterpreted bits. If the sender and receiver use the same representation for numbers (two's complement, almost certainly), you can copy a short
    into an octet, transmit it, and unpack it again at the other end. For numbers in the range 0..127, that's reasonably safe. A simple cast will do the
    right thing.

    If you want to transmit numbers in the range -128..127, it gets more complex because the C++ mapping doesn't state whether an octet is a char, unsigned char, or signed char. So, doing the naive thing and simply using a cast
    might produce the wrong result because of sign extension.

    Of course, these problems are surmountable. However, one of the reasons
    for CORBA is precisely that you shouldn't have to worry about those kinds
    of problems :-) I'd do what you are contemplating only if you are really desperate to save the bandwidth. (And you'd have to have an awful lot
    of these small numbers to make it worthwhile.)

    Cheers,

    Michi.
    --
    Michi Henning +61 7 3891 5744
    Object Oriented Concepts +61 4 1118 2700 (mobile)
    Suite 4, 904 Stanley St +61 7 3891 5009 (fax)
    East Brisbane 4169 michi@ooc.com.au
    AUSTRALIA http://www.ooc.com.au/staff/michi-henning.html

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)