From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa528,9af04b2baa5a026a X-Google-Attributes: gidfa528,public X-Google-ArrivalTime: 2003-03-24 11:49:41 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: marc.gibian@acm.org (Marc S. Gibian) Newsgroups: comp.unix.tru64 Subject: Re: Data structure alignment question Date: 24 Mar 2003 11:49:41 -0800 Organization: http://groups.google.com/ Message-ID: <8df11a0.0303241149.598578d2@posting.google.com> References: <8df11a0.0303191636.389f8f0c@posting.google.com> <8df11a0.0303211248.6d44bd12@posting.google.com> NNTP-Posting-Host: 209.20.248.219 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1048535381 16245 127.0.0.1 (24 Mar 2003 19:49:41 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 24 Mar 2003 19:49:41 GMT Xref: archiver1.google.com comp.unix.tru64:9754 David Konerding wrote in message news:... > > Rather than get into the merits of binary vs. text based protocols, > > this is not an open issue for my current effort because I am porting > > software that has been around for quite a while, with a significant > > installed base. Thus, we need to avoid changing the protocol to > > maintain compatibility with the existing installed product. > > I appreciate your need to maintain protocol compatibility. > > However, my point was to avoid taking a struct, and writing it over the > network directly. Attempting to get a struct to have the alignment of > fields you need by using compiler options is iffy. Even if you don't use > a platform-neutral data encoder like XDR or CORBA, you can achieve layout > of fields in memory without using structs- you have to do the work by > hand, but this is more reliable and portable. Effectively, you end up > writing a function which "packs" a struct into a binary representation > that is equivalent to your protocol format, and another function which > "unpacks" a struct. Is source compatibility still a requirement? > You would have to rewrite some core routines to handle this. Yup... I also need to maintain source compatibility, primarily due to the large size of the existing code base and the "small" effort being directed to the current porting effort. Thus far, it appears that my one padding addition from which my example was drawn has addressed the major issues. There are probably other cases that have not been surfaced yet, but that's the nature of any porting activity. My preference for a distributed application such as this one would have been to use some kind of middleware to handle the messaging, and with it all of the encoding and alignment issues. I suspect CORBA would be overkill, and I am unfamiliar with XDR. I'd have loved to use a universally available RPC (once that was DCE RPC which was everywhere and interoperated with Microsoft RPC), but RPC seems out of vogue now. All of the new XML relatives seem poorly suited to this particular application since it includes very high volume data transfer (> 1 million data records could conceivably be getting moved between the server and client involved), so its text based format would introduce far more inefficiency than this application could accept. DRDA, the wire protocol standard that is used for DB2, seems a reasonable approach, though it would not leave room for application specific messaging, which IS a requirement. I could see something like the old ASN.1 based self-describing data encoding, though that takes a sophisticated parser that probably is not available any longer. So, while it is not a possibility for my current task to change the protocol, I do wonder what would be a good engineering choice were I designing this application from scratch? In the meantime, anyone have any thoughts on my alignment problem? Or am I stuck doing by-hand padding/alignment? Thanks for your thoughts and help, Marc