From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,8bbf2dbc48e08e2f X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!p79g2000cwp.googlegroups.com!not-for-mail From: "lekktu@gmail.com" Newsgroups: comp.lang.ada Subject: Re: Question about Streams and UDP sockets using GNAT.Sockets Date: 18 Jul 2006 04:02:02 -0700 Organization: http://groups.google.com Message-ID: <1153220522.188057.200810@p79g2000cwp.googlegroups.com> References: <1153215666.455584.201990@m73g2000cwd.googlegroups.com> <1fpj192j49rf4$.ma23qkoukku3.dlg@40tude.net> <4i3r3nF215adU1@individual.net> NNTP-Posting-Host: 213.97.59.248 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1153220527 26765 127.0.0.1 (18 Jul 2006 11:02:07 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 18 Jul 2006 11:02:07 +0000 (UTC) User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: p79g2000cwp.googlegroups.com; posting-host=213.97.59.248; posting-account=6KulzA0AAAAYgqXnq9bp1dTrVVTCLyvG Xref: g2news2.google.com comp.lang.ada:5759 Date: 2006-07-18T04:02:02-07:00 List-Id: Thanks, Dmitry and Alex. > I've workarounded this in past versions of GNAT using a direct call to the > Write procedure in Ada.Streams, though you must use a Stream_Element_Array > instead of a String. I've been able to make it work with: ---------------------------------------------------------------------- use Ada.Streams; type Message is new String; procedure Message_Write (Stream : not null access Root_Stream_Type'Class; Item : in Message); for Message'Write use Message_Write; procedure Message_Write (Stream : not null access Root_Stream_Type'Class; Item : in Message) is subtype Message_Array is Stream_Element_Array (1 .. Item'Length); function To_SEA is new Ada.Unchecked_Conversion (Message, Message_Array); begin Write (Stream.all, To_SEA (Item)); end Message_Write; ---------------------------------------------------------------------- Is there any simpler (or more correct) way, or that's about it? Thanks, Juanma