comp.lang.ada
 help / color / mirror / Atom feed
From: "Marin David Condic" <dont.bother.mcondic.auntie.spam@[acm.org>
Subject: Re: adasockets and adatypes
Date: Tue, 4 Sep 2001 09:43:06 -0400
Date: 2001-09-04T13:43:07+00:00	[thread overview]
Message-ID: <9n2lpb$c7b$1@nh.pace.co.uk> (raw)
In-Reply-To: 20010904115244.24236db3.tonygair@blueyonder.co.uk

Look into Ada.Streams and the 'Input and 'Output attributes. That will get a
record type into a stream which you can then send down a socket. I believe
Marc Criley wrote an article on this for a recent issue of Ada Letters, so
if you have it or can get it, you may find a good description there of what
you want to do. It works fine, except for......

You can't guarantee portability using these operations. If you have the same
machine type, OS type, OS version, Compiler brand, Compiler version at both
ends of the stream, you can be pretty sure that what you put into the stream
will be picked apart properly at the other end. Violate one or more of those
constraints and its all up for grabs.

Note that this is a *theoretical* situation only. You might find that all
versions of your compiler represent the data the same way on all platforms.
You might even accidentally discover that multiple brands of compiler do the
same thing. If you test the representation across your intended platforms
and it works - great. Otherwise, you've got to build your own mechanisms to
control the representation and get it into/out of the stream you are sending
up and down the socket.

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.

MDC
--
Marin David Condic
Senior Software Engineer
Pace Micro Technology Americas    www.pacemicro.com
Enabling the digital revolution
e-Mail:    marin.condic@pacemicro.com
Web:      http://www.mcondic.com/


"Tony Gair" <tonygair@blueyonder.co.uk> wrote in message
news:20010904115244.24236db3.tonygair@blueyonder.co.uk...
>
> Does anyone know a way of sending an adatype (especially a record of
string and enumerated types) down a socket so it can be received by another
ada program which recognises the type....
>
> Regards
> Tony Gair





  parent reply	other threads:[~2001-09-04 13:43 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-04 10:53 adasockets and adatypes Tony Gair
2001-09-04 11:37 ` David C. Hoos, Sr.
2001-09-04 12:17   ` Florian Weimer
2001-09-04 14:55     ` David C. Hoos
2001-09-04 15:33       ` Ted Dennison
2001-09-04 15:53         ` David C. Hoos
2001-09-04 18:53           ` Ted Dennison
2001-09-04 20:44             ` David C. Hoos
2001-09-04 21:35               ` Ted Dennison
2001-09-04 15:58         ` Marin David Condic
2001-09-05  9:13   ` Tony Gair
2001-09-04 12:02 ` Marc A. Criley
2001-09-04 13:43 ` Marin David Condic [this message]
2001-09-04 22:12   ` Simon Wright
2001-09-06  7:04     ` Ole-Hjalmar Kristensen
2001-09-07 13:16       ` Peter Dulimov
2001-09-07 14:46         ` Ted Dennison
2001-09-08  5:51         ` Simon Wright
2001-09-06 14:16     ` Marin David Condic
replies disabled

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