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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ac2397ce800de518 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-09-06 00:05:09 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!148.122.208.68!news2.oke.nextra.no!nextra.com!news1.oke.nextra.no.POSTED!not-for-mail Sender: ohk@maestro.clustra.com Newsgroups: comp.lang.ada Subject: Re: adasockets and adatypes References: <20010904115244.24236db3.tonygair@blueyonder.co.uk> <9n2lpb$c7b$1@nh.pace.co.uk> From: Ole-Hjalmar Kristensen Message-ID: User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: 194.143.59.98 X-Complaints-To: news-abuse@nextra.no NNTP-Posting-Date: Thu, 06 Sep 2001 09:04:29 MET DST Organization: Nextra Public Access X-Trace: readme.online.no 999759869 194.143.59.98 Date: 06 Sep 2001 09:04:28 +0200 Xref: archiver1.google.com comp.lang.ada:12785 Date: 2001-09-06T09:04:28+02:00 List-Id: Simon Wright writes: > "Marin David Condic" writes: > > > Note that while I may complain about this from time to time, you're > > still better off than you are with C in the same situation. In C you > > have very little control over representation and in general just > > have to rely on the fact that most C compilers choose to do things > > basically the same way. The one advantage C has in this area is that > > it is at least simpler to take just about any data structure and > > treat it as raw bytes. You can get there in Ada, but it does require > > more work. > > I would have thought the ideal non-automated C way of doing this would > be to define a wire format that is convenient for manipulating > endianness (eg, no packing) and manually stuff this on the way > out/unstuff on the way in. Far less dangerous than trying to > manipulate packed data. > > Sometimes the transport mechanism forces you to use the same length > for every component -- eg, X properties, where you can choose 1/2/4 > byte length and the server byteswaps for you. And don't forget that there are automated tools for doing this in C, the most widespread is probably SUN's XDR/rpcgen, which always has been freely available. From an XDR interface specification, rpcgen will happily generate both server and client side subs, and indeed a skeleton server, if you wish. As the XDR format is a wire format, there are no problems with different compilers and endianness. rpcgen essentially eliminated the extra manual work in writing bread and butter client/server applications years ago. Of course, there is nothing stopping you from calling the generated C stubs from Ada. -- Kabelsalat ist gesund. Ole-Hj. Kristensen