Contents
ErlPort is a library for Erlang which helps connect Erlang to a number of other programming languages. Currently supported external languages are Python and Ruby. The library uses Erlang port protocol to simplify connection between languages and Erlang external term format to set the common data types mapping.
Please check Downloads page for installation instructions and packages to download.
To be able to communicate with an external language first an instance of the language should be created from Erlang. Usually an instance of the language can be created with start/0 or start/1 functions which can be found in an Erlang module for the specific language. During the start call ErlPort trying to start the language specific part of ErlPort library and supply the options passed to start/1 or default options for start/0.
When the language specific part of ErlPort library will be started new OS process will be created and connected to Erlang with a port. At this point ErlPort functions which work with language instances can be used, for example call/4 or cast/2 functions.
For each call of instance related functions like call/4 or cast/2 a message will be created and send to the port. The language specific part of ErlPort library on the other side of the port will handle the message by calling the function or message handler for example. The result of the operation (if applicable) will be passed back to the port and handled by the ErlPort library in Erlang. The same algorithm but in the opposite direction also works if external language want to call a function in Erlang.
At the end of the session when stop/1 function will be called the port connected to the language instance will be closed and the language specific part of ErlPort library will finish the OS process of the instance.