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 14:00:25 PST Path: supernews.google.com!sn-xit-02!sn-xit-04!supernews.com!europa.netcrusader.net!207.172.3.44!feed2.news.rcn.net!rcn!newsfeed1.earthlink.net!newsfeed.earthlink.net!newsmaster1.prod.itd.earthlink.net!newsread1.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3A830904.1814A9BD@earthlink.net> From: "Marc A. Criley" Organization: Quadrus Corporation X-Mailer: Mozilla 4.73 [en] (X11; U; Linux 2.2.14-5.0 i686) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: JGNAT, Byte arrays, and Stream_Element_Arrays References: <3A806533.8EFCFB0@earthlink.net> <3A829458.19037392@earthlink.net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Thu, 08 Feb 2001 22:00:19 GMT NNTP-Posting-Host: 158.252.123.139 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.prod.itd.earthlink.net 981669619 158.252.123.139 (Thu, 08 Feb 2001 14:00:19 PST) NNTP-Posting-Date: Thu, 08 Feb 2001 14:00:19 PST Xref: supernews.google.com comp.lang.ada:5030 Date: 2001-02-08T22:00:19+00:00 List-Id: Stephen Leake wrote: > > "Marc A. Criley" writes: > > > 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? Yes, I'm using Java's socket class for the socket communications. (Keep in mind that while I'm writing Ada, it's _all_ being compiled into Java Byte Code.) Socket packages written in Ada (such as Tardieu's AdaSockets, which is used on the server) at some point import and invoke OS functions, so those are not usable unless I wanted to go the JNI route--which I don't. > > 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? Yes, I am sending structured data as a stream of bytes, and yes, one side of the interface (the JVM client) is converting the data to network byte order. For now, both client and server are running on the same PC-Linux box. > > 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. No, even after the conversion problem was taken care of, JGNAT still sometimes has problems correctly processing stream attributes. I was monitoring the data at the byte level as it came in, and there was nothing wrong with it. The JGNAT generated code simply froze up in some instances. (Same location each time, so it wasn't random with each run.) > 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. I am very much aware that I'm playing close to implementation and platform dependencies :-) And that the solutions I come up with may not be portable across platforms. But I had to start banging my head against the wall somewhere :-) > You need to use the Distributed Annex facilities to make this work > properly (never used them myself, so I can't help more). The idea of trying to get the DSA to work with a natively compiled server and a JVM client scares me even more than using the Java sockets class! > -- > -- Stephe And by the way, got the whole thing happily working. Had to step out and do the "Engineer's Dance"! Marc