comp.lang.ada
 help / color / mirror / Atom feed
From: Jeff C <jcreem@yahoo.com>
Subject: Re: Sending Variable Length Messages with GNAT.Sockets
Date: Mon, 09 May 2005 07:19:56 -0400
Date: 2005-05-09T07:19:56-04:00	[thread overview]
Message-ID: <xYqdnaEh8d_Z2uLfRVn-hw@comcast.com> (raw)
In-Reply-To: <427f3dfa$0$28058$ba620e4c@news.skynet.be>

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.



  parent reply	other threads:[~2005-05-09 11:19 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-09 10:11 Sending Variable Length Messages with GNAT.Sockets markp
2005-05-09 10:39 ` Adrien Plisson
2005-05-09 11:19   ` markp
2005-05-09 11:50     ` Adrien Plisson
2005-05-09 14:30     ` John B. Matthews
2005-05-09 14:51       ` markp
2005-05-09 18:49         ` Adrien Plisson
2005-05-09 19:16         ` Simon Wright
2005-05-10 15:08           ` markp
2005-05-10 20:34           ` Simon Wright
2005-05-11 13:19             ` Marc A. Criley
2005-05-11 17:14               ` tmoran
2005-05-11 21:05               ` Simon Wright
2005-05-12 10:24                 ` Jacob Sparre Andersen
2005-05-14 11:12                   ` Simon Wright
2005-05-09 11:19   ` Jeff C [this message]
2005-05-09 11:35     ` markp
2005-05-09 11:57     ` Adrien Plisson
replies disabled

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