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,484b00716058f98f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-02-08 10:38:01 PST Path: supernews.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!ihug.co.nz!news-hog.berkeley.edu!ucberkeley!newsfeed.stanford.edu!arclight.uoregon.edu!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: JGNAT, Byte arrays, and Stream_Element_Arrays Date: 08 Feb 2001 13:28:53 -0500 Organization: NASA Goddard Space Flight Center Message-ID: References: <3A806533.8EFCFB0@earthlink.net> <3A829458.19037392@earthlink.net> NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 981657731 24423 128.183.220.71 (8 Feb 2001 18:42:11 GMT) X-Complaints-To: dscoggin@cne-odin.gsfc.nasa.gov NNTP-Posting-Date: 8 Feb 2001 18:42:11 GMT User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.6 Xref: supernews.google.com comp.lang.ada:5009 Date: 2001-02-08T18:42:11+00:00 List-Id: "Marc A. Criley" writes: > I'm trying to implement an instance of the "Ada can be anywhere" > philosophy--compiled natively on the server (GNAT 3.13p) and to Java on > the client (JGNAT 1.1p). (I've just started messing around with JGNAT, > so right now I'm in the "experimental flailing" stage :-) Ok. > Based on some past work I did with tying Streams and their > associated attributes together with sockets, I've attempted to adapt > that code to work with Java's sockets, hence the work with > byte_Arr(ays). I've had partial success, at least with the specific > data streams with which I'm working. Now I'm confused. Why use "Java's sockets" if you are attempting an "all Ada" approach. I guess you mean "use a Java 2 socket class", because there is no equivalent Ada package? > I did discover that I had to reverse the order of the bytes, at > least on a PC linux platform--so as it turned out that pretty much > ruled out the possibility of bulk conversion anyway. Hmm. This implies you are attempting to send structured data as stream of bytes, and some of the data is multibyte (eg 16 bit integers), and one side of the stream interface is converting to network byte order but the other side isn't. Now I'm really confused! Or are the client and server different machines with different native byte order? > Plus, JGNAT's implementation of some of the Stream attributes, like > 'Input, seems a little shaky. Sometimes doing a String'Input of data > freezes up, even though the data was of course sent via > String'Output. Certainly if one side is doing conversions to network byte order and the other isn't, you will have problems. The string length will be wrong, for one. > > Are you importing a serialized object? Then maybe you can > > re-import the relevant functions, but declare them to use > > Stream_Element_Array rather than Java.byte_Arr_obj. this might not > > work, if the pointers really are different. > > The native, server side is the one in control of the data objects, so > there's no explicit interaction between _Java_ language software > (objects) and Ada software. It's all Ada, with the client software > being compiled to JBC (I know the client is interacting with "Java" > software, but that software is being treated more as a library > resource.) Ah. So you have native (what machine?) Ada code generating a stream from structured data, but then you are reading that stream with a Java stream library. Sounds like a recipe for trouble. What does JGNAT do for Ada.Streams? Maybe that's what you are using. I seem to recall that the JVM spec defines byte order in streams. Ada makes no guarrantee that a stream written by one compiler/machine will be readable by a different compiler/machine. Here you have GNAT/PC (I guess) writing, and JGNAT/JVM reading, so it is allowed to not work. You need to use the Distributed Annex facilities to make this work properly (never used them myself, so I can't help more). > > Is Stream_Element actually 8 bits? > > Yes: type Stream_Element is mod 2 ** Standard'Storage_Unit; > > That's GNAT's implementation on Linux, the LRM does not specify a size. Exactly, that's why I asked. I'm guessing that Standard'Storage_Unit is 8, on both the native and JVM machines. Actually, I'd be surprised if it isn't (but there are machines where it isn't). -- -- Stephe