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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,deffccd74319c23d X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news2.google.com!proxad.net!proxad.net!skynet.be!newspost001!tjb!not-for-mail Date: Mon, 09 May 2005 12:39:40 +0200 From: Adrien Plisson User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) X-Accept-Language: fr-fr, fr-be, fr, en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Sending Variable Length Messages with GNAT.Sockets References: <1115633512.107824.259680@g14g2000cwa.googlegroups.com> In-Reply-To: <1115633512.107824.259680@g14g2000cwa.googlegroups.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <427f3dfa$0$28058$ba620e4c@news.skynet.be> Organization: -= Belgacom Usenet Service =- NNTP-Posting-Host: 3065fdeb.news.skynet.be X-Trace: 1115635194 news.skynet.be 28058 81.246.233.244:4133 X-Complaints-To: usenet-abuse@skynet.be Xref: g2news1.google.com comp.lang.ada:10966 Date: 2005-05-09T12:39:40+02:00 List-Id: markp wrote: > My question is: What if the data type "Msg_Type" was a variable length > message? Is there a way to send only "x" bytes for Msg_Type, and not > the entire thing? it depends on your requirements. if your receiver is an Ada software, use 'Output instead of 'Write, and there will be no problems. in any case, you can use 'Write, but you will have no way to tell the size of the message from the stream, unless the message itself contains its length (a pretty common case). reading variable length messages with 'Read can become really difficult. now choose the way you implement your variable length message. there are three kind of variable length types: - variant records with a discriminant - arrays - tagged types each have their pros and their cons... also, i can think of no way to send "x" bytes of a type and not the entire thing, unless writing your own stream input and output procedures. -- rien