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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham 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!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Alex R. Mosteo" Newsgroups: comp.lang.ada Subject: Re: Question about Streams and UDP sockets using GNAT.Sockets Date: Wed, 19 Jul 2006 12:36:37 +0200 Message-ID: <4i6g4uF2bv8pU1@individual.net> References: <1153215666.455584.201990@m73g2000cwd.googlegroups.com> <1fpj192j49rf4$.ma23qkoukku3.dlg@40tude.net> <4i3r3nF215adU1@individual.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: individual.net 8vT+wktQ1oSItdTfGJ6xSwrjdVw2v6bl4Xl+qbV9mE24in1bk= User-Agent: KNode/0.10.2 Xref: g2news2.google.com comp.lang.ada:5803 Date: 2006-07-19T12:36:37+02:00 List-Id: Randy Brukardt wrote: > "Alex R. Mosteo" wrote in message > news:4i3r3nF215adU1@individual.net... > ... >> 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. Doing so your array is >> transferred in a single call and packet. (Contrarily to using the 'Write >> attribute of Stream_Element_Array, that will also make a call for every >> element, which is very CPU expensive for large arrays). > > If the type you are sending is more complex than a simple array, you > probably should try to use 'Write (Unchecked_Conversion won't necessarily > work on complex types). The best way to do it is to create a buffer stream > type that simply puts the bytes in a Stream_Element_Array. Then use the > direct call to the Write procedure of the socket stream. I also have implemented a stream type to do this. Take a look to the child packages under Agpl.Streams: https://svn.mosteo.com/public/agpl/ and particularly to https://svn.mosteo.com/public/agpl/agpl-streams-circular.ads https://svn.mosteo.com/public/agpl/agpl-streams-circular_unbounded.ads These may involve some extra copying around, but you can adapt them to avoid it.