From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Help with type definition
Date: Fri, 16 May 2014 09:54:18 +0200
Date: 2014-05-16T09:54:18+02:00 [thread overview]
Message-ID: <1fg1g0pncjb4l$.1qve7hld7nxqv.dlg@40tude.net> (raw)
In-Reply-To: 8beec1c1-9ca2-44fc-9d7e-0cd0aa772dcc@googlegroups.com
On Fri, 16 May 2014 00:37:25 -0700 (PDT), hanslad@gmail.com wrote:
> I need an advise on how to define a type in my project.
> I want to implement a network protocol with the following definition on the type "string":
>
> "All String values are encoded as a sequence of UTF8 characters without a
> null terminator and preceded by the length in bytes.
> The length in bytes is encoded as Int32. A value of -1 is used to indicate
> a 'null' string."
That is not definition of a type. It is definition of encoding. Though it
does not define the way the string length is encoded. Why -1 should
indicate null string and not 0 is a mystery.
[Usually, unless the network transport has fixed-size blocks (real-time
protocols do), for a stream-oriented transport, it is better to encode
counts using chained codes. That reduces space required for lesser numbers.
E.g. UTF-8 uses chained codes to encode character code points.]
> The string is used in different datastructures send on network eg. like
> the one implemented in "Node" type below.
> Am I on the right track here?
No. Internal representation and types have nothing to do with the protocol,
except for encoding and decoding stages (presentation layer). You said, it
is a string, let it be String, Wide_Wide_String, Unbounded_String.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2014-05-16 7:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-16 7:37 Help with type definition hanslad
2014-05-16 7:54 ` Dmitry A. Kazakov [this message]
2014-05-16 10:03 ` G.B.
2014-05-16 11:26 ` Jacob Sparre Andersen
2014-05-16 15:38 ` Shark8
2014-05-16 15:50 ` Simon Wright
2014-05-16 16:30 ` Shark8
2014-05-16 11:29 ` Jacob Sparre Andersen
2014-05-16 12:29 ` G.B.
2014-05-16 17:57 ` Jeffrey Carter
2014-05-21 20:45 ` hanslad
2014-06-27 22:05 ` hanslad
2014-06-28 7:26 ` Shark8
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox