comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Binary and XML serialization of types
Date: Fri, 24 Jan 2014 11:01:18 +0100
Date: 2014-01-24T11:01:18+01:00	[thread overview]
Message-ID: <14k7gbu5ws82b.3pn20kh5ci50.dlg@40tude.net> (raw)
In-Reply-To: 5bf8c737-b99d-4069-885f-03fe82f06cc6@googlegroups.com

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


  reply	other threads:[~2014-01-24 10:01 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-23 18:53 Binary and XML serialization of types hanslad
2014-01-23 19:15 ` adambeneschan
2014-01-23 19:17   ` adambeneschan
2014-01-23 19:58     ` hanslad
2014-01-23 20:03       ` adambeneschan
2014-01-23 21:00       ` Dmitry A. Kazakov
2014-01-24  8:54         ` hanslad
2014-01-24 10:01           ` Dmitry A. Kazakov [this message]
2014-01-24 14:44             ` hanslad
2014-01-24 15:22               ` Dmitry A. Kazakov
2014-01-31  9:51                 ` hanslad
2014-01-31 10:49                   ` Dmitry A. Kazakov
2014-02-04 10:33                     ` AdaMagica
2014-02-04 11:14                       ` Dmitry A. Kazakov
2014-02-04 11:20                         ` AdaMagica
2014-02-04 13:04                           ` Dmitry A. Kazakov
2014-02-04 17:16                             ` AdaMagica
2014-02-04 17:57                               ` Dmitry A. Kazakov
2014-02-04 22:34                               ` Simon Wright
2014-02-05  9:02                                 ` AdaMagica
2014-02-05  9:39                                   ` Simon Wright
2014-02-05 10:35                                   ` Dmitry A. Kazakov
2014-02-05 13:03                                     ` AdaMagica
2014-02-05 13:44                                       ` G.B.
2014-02-05 15:34                                       ` Niklas Holsti
2014-02-06  1:32                                       ` adambeneschan
2014-01-24 17:36             ` Simon Wright
2014-01-24  8:44       ` Georg Bauhaus
2014-01-24 17:13         ` Simon Wright
2014-01-23 22:44   ` Simon Wright
2014-01-23 23:43     ` adambeneschan
2014-01-24  0:58       ` Randy Brukardt
2014-01-24  8:29       ` Oliver Kleinke
2014-01-24 16:22         ` adambeneschan
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox