comp.lang.ada
 help / color / mirror / Atom feed
From: Mark Gardner <magardner2017@gmail.com>
Subject: Re: Sockets, Streams, and Element_Arrays: Much confusion
Date: Sat, 31 Dec 2022 21:36:40 +0200	[thread overview]
Message-ID: <6183be57-2796-0ab7-739f-a5b557083ee6@gmail.com> (raw)
In-Reply-To: lyo7rjpj5w.fsf@pushface.org

On 31/12/2022 19:39, Simon Wright wrote:
> [...]
> 
> The approach we adopted was to create a 'memory stream', which is a
> chunk of memory that you can treat as a stream (see for example
> ColdFrame.Memory_Streams at [1]). With Ada2022, you should be able to
> use Ada.Streams.Storage.Bounded[2].
> 

Wait, so if I know what shape my data is, and use a memory_stream (like 
the one in the Big Online Book of Linux Ada Programming chapter 11 [1]), 
I'm fine using Stream, in conjunction with Get_Address? That's 
wonderful. Not at all frustrated that I just wasted approximately three 
working days looking for a solution to a problem that didn't exist.

> Message'Write the record into the memory stream;
> transmit the written contents as one datagram.

I'm guessing with Memory_Stream'Write(Socket_Stream, Buffer);?

> 
> To read, create a memory stream large enough for the message you expect;
> read a datagram into the memory stream;
> Message'Read (Stream => the_memory_stream, Item => a_message);

Does this second buffer need to be added? If the datagram arrives (UDP), 
shouldn't GNAT.Sockets.Stream() be able to handle it?
> 
> You can use gnatbind's switch -xdr to "Use the target-independent XDR
> protocol for stream oriented attributes instead of the default
> implementation which is based on direct binary representations and is
> therefore target-and endianness-dependent".

Oh fun, I didn't think of that aspect. Thanks! Would I have to pass it 
as a command line flag, or would there be some kind of pragma I could use?

Thanks for the help so far, and happy new year!

[1] http://www.pegasoft.ca/resources/boblap/11.html#11.12

  reply	other threads:[~2022-12-31 19:36 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 [this message]
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
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