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,deffccd74319c23d X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Mon, 09 May 2005 06:19:32 -0500 Date: Mon, 09 May 2005 07:19:56 -0400 From: Jeff C User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: 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> <427f3dfa$0$28058$ba620e4c@news.skynet.be> In-Reply-To: <427f3dfa$0$28058$ba620e4c@news.skynet.be> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 24.147.74.171 X-Trace: sv3-Athe7KfD8rcnsT/pGmjkluEfRaNaC/rT27Kul5gO9KMg1jrDfUJrsCZpDFyciTzhnFHRoNkQomGw3nF!90i+LsRxaBUnLhL7KLUO/2/1lkqTKcvtfs4tV7hMaw9H6ZrOEyUU6+Mf7658DA== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.32 Xref: g2news1.google.com comp.lang.ada:10969 Date: 2005-05-09T07:19:56-04:00 List-Id: Adrien Plisson wrote: > 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. > Note that the last statement is almost written as if this is a bad thing. (And I suspect someone that tried it for the first time might feel that way)...But, there is really nothing wrong with writing your own input and output procedures. It is mildly painful once and then the rest of the code ends up pretty clean.