lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On 29 October 2011 22:30, David Hollander <> wrote:
> Let me proposes a different protocol that might suit your needs:
> 1st and 2 byte: message length
> X bytes: message
> message = any serialized lua value.
> Pass (senderIP, message) to a handler. The end :)

Indeed, something like protocol buffers even easily automates this approach.

What kind of protocol to use depends a lot on the needs of the
application. XMPP and even ZeroMQ are high-level protocols (of
different degrees) that give a framework for application protocols.
They all have their strengths and weaknesses.

For example, XMPP provides authentication, identity, distribution,
extensibility, and standard features such as encryption, compression,
connection resumption, etc. It doesn't deal so well with binary
payloads, adds routing overhead, and is more work to parse than a
TLV-encoded protocol.

ZeroMQ is a more suitable transport for a custom binary protocol, it
has built-in framing, nifty abilities like efficient intra- and
inter-process communication, multicasting, etc. It is not so good at
the identity aspect, encryption, or robustness when facing public

It's not always obvious, especially if one isn't a protocol geek, what
to build network-enabled applications on top of. The internet is full
of protocol abuse, from HTTP-centric hacks like comet to a case I saw
once of someone base64-encoding video frames and sending them over an
XMPP stream. Oh, and I've seen SMTP used for machine-to-machine
communication on a local network (Python has an SMTP client *and
server* in the standard library, believe it or not).

Some of these abuses are pure monsters, while some are "wrong" but
necessary hacks in a sense, e.g. comet, and fun things I've seen like
SSH-over-XMPP... working through any number of proxies and firewalls.
The internet is an interesting beast...