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,f25e636d6b770960 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-03-25 14:36:48 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news-hub.siol.net!zur.uu.net!ash.uu.net!xyzzy!nntp From: Jeffrey Carter Subject: Re: Last stream problem: byte order X-Nntp-Posting-Host: e246420.msc.az.boeing.com Content-Type: text/plain; charset=us-ascii Message-ID: <3C9FA490.62FAEE8F@boeing.com> Sender: nntp@news.boeing.com (Boeing NNTP News Access) Content-Transfer-Encoding: 7bit Organization: The Boeing Company X-Accept-Language: en References: Mime-Version: 1.0 Date: Mon, 25 Mar 2002 22:28:32 GMT X-Mailer: Mozilla 4.73 [en]C-CCK-MCD Boeing Kit (WinNT; U) Xref: archiver1.google.com comp.lang.ada:21660 Date: 2002-03-25T22:28:32+00:00 List-Id: Erik Sigra wrote: > > Now my stream application almost works. The last remaining problem seems to > be byte order. The server is programmed in C++ with Qt and the client is > programmed in Ada with adasockets-1.0. The last thing I did was to change the > byte order in the server > ("the_stream.setByteOrder(QDataStream::LittleEndian);"). After that the > numbers came out right at the other end. > > However, this may not be a safe solution. The safe way would probably be to > always have the network communication in BigEndian format and make sure the > client always obeys this, regardless of the platform. > > So how does one set the byte order to BigEndian on the Ada side? Or is there > a different, better idea? If you want your code to deal with things with a specific byte order regardless of the platform, you'll need to read individual bytes and put them together properly, and decompose things into bytes and write them in the appropriate order. Since this requires explicit processing in your Ada code, it doesn't really matter which endianness you choose, as long as everything uses the same endianness. -- Jeffrey Carter