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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,adb01e044e3e5aec X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-01-31 13:21:43 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!syros.belnet.be!news.belnet.be!fr.usenet-edu.net!usenet-edu.net!enst.fr!not-for-mail From: "David C. Hoos" Newsgroups: comp.lang.ada Subject: Re: Hints for networking Date: Fri, 31 Jan 2003 15:21:34 -0600 Organization: ENST, France Message-ID: References: Reply-To: "comp.lang.ada mail to news gateway" NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1044048102 13954 137.194.161.2 (31 Jan 2003 21:21:42 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Fri, 31 Jan 2003 21:21:42 +0000 (UTC) To: "comp.lang.ada mail to news gateway" Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.1 Precedence: list List-Id: comp.lang.ada mail to news gateway List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: archiver1.google.com comp.lang.ada:33658 Date: 2003-01-31T15:21:34-06:00 Hi Jano, I have written many many network protocol representations using Ada95 streams. The elegance of Ada Streams, and the simplicity of their use once you have made the effort to properly define your types and their stream attributes really makes the effort worthwhile. Here are some hints and rules needed to do this successfully: These rules are based on the presumption that there is a specific network representation required by your protocol. 1, This rule number 1 is very important. NEVER base any value written to a stream on the standard Ada type Integer. You should always define project-specific types that do not depend on implementations that are subject to variation between compilers or platform types. For example, you can base integer types on those available in the package Interfaces -- Integer_16, Unsigned_16, etc. That's what the Interface package is for -- i.e. to permit writing portable code for interfaces. 2. You need to write stream attributes for multi-octet numbers that respect the bendiness of your platform. Even when you've been told that "this only has to run on Sparc," sooner or later your code will also need to run on Intel, so I've always taken the trouble to deal with bendiness. 3. All objects written to a stream must have a 'Size that is an integer multiple of 8. So, if you have an octet with two four-bit fields, I make them into a record type, and write the stream attributes for that record. I've done things like a record that has a 31-bit field, and a 1-bit field. Happy streaming! David Hoos ----- Original Message ----- From: "Jano" <402450@cepsz.unizar.es> Newsgroups: comp.lang.ada To: Sent: Friday, January 31, 2003 10:37 AM Subject: Hints for networking > Hello everybody. > > I'm about to program a networking package for the first time in Ada and > am somewhat undecided the way to go. I'd like to hear some pointers for > examples or hints. > > The protocol has some fixed-size packets and others of unknown size (but > with known headers which contains the full size). I'm wondering what > representation clauses could help me, if any. Also, I've my doubts about > streams, because in the past I've tried them to write files and in Gnat > I couldn't manage to output exact sized types except uncheckedconverting > them into byte arrays. For example an integer subtype with > representation clauses for 16 bits was always dumped as its base type, > i.e. 32 bits. Frankly, the RM is too dense for me so some beginner > documentation would be very useful. > > I've read some tutorials and books from adapower lately but can't find > something more on the subject. Clues welcomed. > > TIA, > > -- > ------------------------- > Jano > 402450[at]cepsz.unizar.es > ------------------------- > _______________________________________________ > comp.lang.ada mailing list > comp.lang.ada@ada.eu.org > http://ada.eu.org/mailman/listinfo/comp.lang.ada >