provides C-side functionality for constructing,
manipulating, and accessing C encodings of Erlang binary terms. Also
included are functions for dealing with memory allocation in term
(de)construction and manipulation, accessing global names, and reporting
errors. In a little more detail:
For handling the Erlang term format, including memory management. In particular, these provide conversion to and from C structs similar to Erlang terms, allowing higher-level manipulation of data.
For providing a connection with Erlang through a distributed Erlang node.
For printing error messages.
For providing access to globally registered names.
For providing the facility to store and back up key-value pairs. This provides some of the functionality of ETS tables and can be backed up or restored from a Mnesia table on a linked Erlang node.
In addition, the Erlang external term format is
a representation of an Erlang term as a sequence of bytes: a binary. You
can convert between the two representations in Erlang using the BIFs
binary_to_term/1. We discuss this in
more detail in Port Programs.
In this section, we’ll revisit the example of the factorial server just given for Java, this time in C, based on the example in the online Interoperability Tutorial for Erlang:
1 /* fac.c */ 2 3 #include <stdio.h> 4 #include <sys/types.h> 5 #include <sys/socket.h> ...