comp.lang.ada
 help / color / mirror / Atom feed
From: sjw <simon.j.wright@mac.com>
Subject: Re: Cross-platform issues
Date: Mon, 7 Dec 2009 13:05:54 -0800 (PST)
Date: 2009-12-07T13:05:54-08:00	[thread overview]
Message-ID: <a7205b06-5510-4d1e-96b2-0db87f575997@z41g2000yqz.googlegroups.com> (raw)
In-Reply-To: hfhf9l$2gh$1@news.albasani.net

On Dec 6, 11:39 pm, Leslie <jlturr...@centurytel.net> wrote:

>         What I'm working on is a product that I want to conform as
> closely as possible to the one that inspired it.  The original
> emits trace data with things like field length info in 4-byte
> integers, for example. I suppose that using a derived type to
> ensure that in my implementation those fields conform with the
> original is one way to do it, but is that accepted practice, or
> is there a more usual one?

I'd start by defining the data to be sent over the net. You could base
your data structures on the types in package Interfaces, then there's
no worry about the size of Interfaces.C.int.

Then I'd format the data to be sent using the stream attribute
('Write, most likely). The simpler your types the less likely is it
that compilers will disagree about the way the data is mapped to the
output stream of octets.

If you're using GNAT, the package GNAT.Sockets provides stream-
oriented interfaces to IP sockets.

Also if you're using GNAT you can transparently convert to/from
network byte order; take the file s-strxdr.adb from your compiler's
Ada library (.../adainclude/), copy to your source directory, rename
to s-stratt.adb, build using gnatmake -a to force local rebuild of the
affected parts of the RTL.



  parent reply	other threads:[~2009-12-07 21:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-05 21:23 Cross-platform issues Leslie
2009-12-06 17:13 ` John B. Matthews
2009-12-06 23:39   ` Leslie
2009-12-07  6:03     ` Per Sandberg
2009-12-07 21:05     ` sjw [this message]
2009-12-08  0:33     ` Randy Brukardt
2009-12-08  0:33     ` tmoran
2009-12-08  9:02       ` Martin
2009-12-08 19:46 ` Leslie
replies disabled

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