comp.lang.ada
 help / color / mirror / Atom feed
From: "lekktu@gmail.com" <lekktu@gmail.com>
Subject: Re: Question about Streams and UDP sockets using GNAT.Sockets
Date: 18 Jul 2006 04:02:02 -0700
Date: 2006-07-18T04:02:02-07:00	[thread overview]
Message-ID: <1153220522.188057.200810@p79g2000cwp.googlegroups.com> (raw)
In-Reply-To: 4i3r3nF215adU1@individual.net

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




  reply	other threads:[~2006-07-18 11:02 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-18  9:41 Question about Streams and UDP sockets using GNAT.Sockets lekktu
2006-07-18  9:55 ` Dmitry A. Kazakov
2006-07-18 10:25   ` Alex R. Mosteo
2006-07-18 11:02     ` lekktu [this message]
2006-07-18 14:25       ` Alex R. Mosteo
2006-07-18 14:58         ` lekktu
2006-07-18 20:52       ` Samuel Tardieu
2006-07-18 20:58     ` Randy Brukardt
2006-07-19 10:36       ` Alex R. Mosteo
2006-07-19 18:50       ` Simon Wright
2006-07-18 19:07   ` Jeffrey R. Carter
2006-07-18 20:13     ` Dmitry A. Kazakov
2006-07-19  0:32       ` Jeffrey R. Carter
2006-07-19  8:12         ` Dmitry A. Kazakov
2006-07-19 18:59 ` Simon Wright
2006-07-19 20:54   ` lekktu
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox