From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Sockets, Streams, and Element_Arrays: Much confusion
Date: Sun, 1 Jan 2023 18:17:07 +0200 [thread overview]
Message-ID: <k1dq03F95j7U1@mid.individual.net> (raw)
In-Reply-To: <lyk027p2eg.fsf@pushface.org>
On 2023-01-01 1:41, Simon Wright wrote:
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
>
>> My advise would be not to do this. It is wasting resources and
>> complicated being indirect when 'Write and 'Read are
>> compiler-generated. If you implement 'Write and 'Read yourself, then
>> why not calling these implementations directly. It just does not make
>> sense to me. I always wonder why people always overdesign
>> communication stuff.
>>
>> Build messages directly in a Stream_Element_Array. Use
>> system-independent ways to encode packet data. E.g. chained codes for
>> integers. Mantissa + exponent for real numbers. If you have Booleans
>> and enumerations it is a good idea to pack them into one or two octets
>> to shorten the packets. All this is very straightforward and easy to
>> implement.
>
> It has to depend on the design criteria.
>
> If you need something now, and it's not performance critical, and you
> have control over both ends of the channel, why not go for a
> low-brain-power solution?
>
> On the other hand, when faced with e.g. SNTP, why not use Ada's
> facilities (e.g. [1]) to describe the network packet and use
> unchecked conversion to convert to/from the corresponding stream
> element array to be sent/received?
>
> [1]
https://sourceforge.net/p/coldframe/adasntp/code/ci/default/tree/SNTP.impl/sntp_support.ads
One reason is that the Scalar_Storage_Order representation aspect is
GNAT-specific, so that code is not really "Ada code", but "GNAT code".
With most processors now being little-endian, while network traffic is
still big-endian, byte-endianness conversion is usually necessary.
next prev parent reply other threads:[~2023-01-01 16:17 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-31 12:11 Sockets, Streams, and Element_Arrays: Much confusion Mark Gardner
2022-12-31 13:11 ` Dmitry A. Kazakov
2022-12-31 13:50 ` Mark Gardner
2022-12-31 14:16 ` Dmitry A. Kazakov
2022-12-31 15:18 ` Jeffrey R.Carter
[not found] ` <de32dc82-ba42-4b27-a140-ddab9587219fn@googlegroups.com>
2022-12-31 22:49 ` Jeffrey R.Carter
2022-12-31 22:55 ` Dmitry A. Kazakov
2022-12-31 17:39 ` Simon Wright
2022-12-31 19:36 ` Mark Gardner
2022-12-31 20:16 ` Dmitry A. Kazakov
2022-12-31 23:41 ` Simon Wright
2023-01-01 9:48 ` Dmitry A. Kazakov
2023-01-01 16:11 ` Simon Wright
2023-01-01 16:17 ` Niklas Holsti [this message]
2023-01-05 7:55 ` Daniel Norte de Moraes
2023-01-05 10:35 ` Dmitry A. Kazakov
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox