[erlang-questions] C data encoding/decoding

Bob Cowdery Bob.Cowdery@REDACTED
Mon Sep 11 13:57:02 CEST 2006


Hi

Having got a C Port client and server working I am now moving that into the real application. Now comes the question of sending and receiving real messages between C Nodes. 

The data that forms the interface between these two nodes is C structs. Some of these structs are arrays or may contain arrays of structs or other simple types. One particular struct also has unions in it.

I started out just using erl_format() which got me so far. I really only found it suitable for simple parameters and fixed structures. I then read the Erlang Interface document. From this it definitely seems I should be using the ei module. The external format looks like its much more adept at dealing with dynamic data. It is quite a difficult read though and there arn't any examples. Before I write too much codeI want to be sure this is the right approach so a few questions to anyone kind enough to give guidence.

1. Is the ei module the right one to use for reasonably complex dynamic data or am I not getting the full milage out of erl_format().
2. If I use the external format is that suitable for digestion by a pure Erlang node as I don't expect at least one end of this interface to stay in C.
3. I can see an ei_send() takes a message in binary format (i'm assuming this is the same as external format). However, the receive functions don't explicitly say what they expect. I assume ei_receive accepts a message in binary format.
4. I could really do with an example of packing and unpacking say an array of structs to/from binary format. Can anyone point me to such an example.

All help appreciated.

Thanks
Bob






More information about the erlang-questions mailing list