Cover by Francesco Cesarini, Simon Thompson

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

C Nodes

The erl_interface library 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:

erl_marshal, erl_eterm, erl_format, and erl_malloc

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.

erl_connect and ei_connect

For providing a connection with Erlang through a distributed Erlang node.

erl_error

For printing error messages.

erl_global

For providing access to globally registered names.

registry

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 term_to_binary/1 and 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> ...

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required