From mboxrd@z Thu Jan 1 00:00:00 1970 Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: In memory Stream Date: Sat, 17 Feb 2024 22:33:17 +0100 Organization: A noiseless patient Spider Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 17 Feb 2024 21:33:16 -0000 (UTC) Injection-Info: dont-email.me; posting-host="662d3d0c8c5c8e50d9cee14792db885b"; logging-data="653892"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19/gtjOUu9VvFhPTZU6TZ6JXhsKxgPalFg=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:WBM+cpF19QdkH8/9vSz36LmKmCM= In-Reply-To: Content-Language: en-US Xref: news.eternal-september.org comp.lang.ada:66081 List-Id: On 2024-02-17 19:09, Simon Wright wrote: > I can't remember at this distance in time, but I think I would have > liked to construct a memory stream on the received UDP packet rather > than copying the content; the compiler wouldn't let me. Perhaps worth > another try. UDP is a kind of thing... Basically, there is no use of UDP except for broadcasting, e.g. in LAN discovery. In all other cases it is either TCP or multicast. Since UDP does not guarantee either delivery or ordering. It would be a huge overhead to implement reliable buffered streams on top of UDP, with sequence numbers, acknowledgements, re-sending, reordering etc. As for taking apart a UDP packet, it is straightforward. You simply declare a stream element array of the packet size and map it on the packet using: pragma Import (Ada, A); for A'Address use UDP_Packet'Address; And somewhere pragma Assert (Stream_Element'Size = 8); just in case... -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de