views:

124

answers:

5

As I hate reinventing the wheel, I wonder if there are any commonly used packaged out there for doing hte simple job of communicating (key,value) pairs of data betweeen two network endpoints (probably TCP/IP is the most likely carrier). I would like something that works in any environment, which for me means Unix/Linux-style socket API written in C or maybe C++. Java is nice, but only Java makes it hard to integrate into binary programs. C# etc. is out due to the need to be portable to Linux hosts.

Is there such a beast?

+1  A: 

Socket-level APIs are the way to go if you want complete portability. I suppose there are packages for each language that can do the proper bit-molding in both directions, but I'm not aware of any single package that is ported to all these languages.

Shachar
+5  A: 

Consider using JSON? There are libraries available for most programming languages.

tunaranch
That looks like a very good candidate! Thanks!
jakobengblom2
JSON is easy to decode in almost ANY language.. even if the Linux peer just saves it for something else to worry about. +1 , Good answer.
Tim Post
+2  A: 

Google has a data interchange format called Procotol Buffers you may want to consider.

JesperE
That also looks like a good candidate... except that maybe the need to declare things is a problem if you want to build a generic receiver end that muxes out data to various receivers. And you don't want to rebuild all every time.
jakobengblom2
I would guess that Protocol Buffers is (or can be made) much more efficient than JSON or YAML.
JesperE
Can anyone say over-engineering?
Frank Krueger
Yes. MSI is over-engineered. Corba is over-engineered. Protocol Buffers is not.
JesperE
A: 

There's also bencoding. There's probably libraries (torrent libraries) that will parse it easily enough.

jdizzle
+1  A: 

netstrings are an old solution if you would like to have minimal overhead.

Martin Redmond
Netstrings seems odd to me. The guy wrote a short paper describing how every C programmer transmits strings and then claims that they will secure the web? Am I missing something?
Frank Krueger
If you know the length of a string before you begin to process it you can prevent one major security exploit: buffer overruns.
Martin Redmond