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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: border1.nntp.dca3.giganews.com!backlog3.nntp.dca3.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Binary and XML serialization of types Date: Fri, 24 Jan 2014 11:01:18 +0100 Organization: cbb software GmbH Message-ID: <14k7gbu5ws82b.3pn20kh5ci50.dlg@40tude.net> References: <20a36d96-850e-4020-8dfa-777eb9c944f4@googlegroups.com> <9e27abb7-e944-4bd4-a10c-600fe4da7872@googlegroups.com> <56a5aeb6-8704-457c-a24f-b664746afe72@googlegroups.com> <13pvagjpwejni$.1e8ll5btxg1f5$.dlg@40tude.net> <5bf8c737-b99d-4069-885f-03fe82f06cc6@googlegroups.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: I5Na6+WsEzT8WoegI0VZTA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 X-Original-Bytes: 3447 Xref: number.nntp.dca.giganews.com comp.lang.ada:184540 Date: 2014-01-24T11:01:18+01:00 List-Id: On Fri, 24 Jan 2014 00:54:49 -0800 (PST), hanslad@gmail.com wrote: > In short, I want to develop a client/server library to encode (and decode) > structures of data(records) and request the data over tcp. > Is there a faster way to do this than using streams? That depends on what you mean here under using streams: 1. Streams for in-memory format transformations 2. Streams as an interface to TCP/IP sockets, e.g. GNAT socket streams. In the case 1, the alternatives are representation clauses + type conversion or plain conversion operations. Whatever difference might be, it is not sufficient. In the case 2, you should consider using packets instead of a raw octet stream. Typically you would form an outgoing packet in the memory, using whatever means (e.g. by a string-mapped stream) and then send the packet out as a whole. It is especially important to do if you are going to use NO_DELAY socket option. > Also, the encoding of a structure could be dependent of where the > structure is used. Say, the first byte sent over wire tells if the > "Identity" field in a record should be decoded as a 2 or 4 byte integer. Is it a custom protocol you are going to invent? Anyway, the protocols usually deploy some sort of packet header to describe the request and the body of. The most efficient way is when the body length can be determined from the header. You read the body into memory and then parse it, e.g. using a string-mapped stream. > For me it would be locical to separate all the "wire information" from the > type information. Today, the binary and xml encoding scheme is defined, > and I had hope to be able to separate this in different packages. That is doable. > What is the locical way to do this? Deploying OSI model is one way. I don't know how far up you want to go with XML in breaking the OSI hierarchy. XML does not make any sense anyway, but considering making it human-readable as a purpose, you must break it all way up to the application level, e.g. by exposing names of the fields, having special representations of the fields, a nasty thing. Otherwise, you use XML sealed in the presentation layer, by packing everything under one key/value pair. It is easy to implement, does not make sense either, typical XML. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de