Erlang Port drivers and Erl_interface

Casper casper2000a@REDACTED
Thu Jan 27 13:26:11 CET 2005


Klacke,

Thanks for your advice.

Let's say I want to pass a complex structure back and forth. And I opened
the linked-in driver port using binary. Then can I use term_to_binary and
binary_to_term in the Erlang side and erl_decode, erl_encode and other erl
interface functions in the C side?

- Eranga



-----Original Message-----
From: klacke@REDACTED [mailto:klacke@REDACTED] 
Sent: Thursday, January 27, 2005 4:36 PM
To: casper2000a@REDACTED
Cc: erlang-questions@REDACTED
Subject: Re: Erlang Port drivers and Erl_interface

On Wed, Jan 26, 2005 at 10:06:15PM +0600, casper2000a@REDACTED wrote:
> Hi All,
> 
> With an Erlang Port driver, is it possible to use 
> Erl_interface functions for message 
> Encoding/Decoding? What's the best method to use?
> 


It depends on the complexity/structure of the messages between the
driver and erlang-code. If you want to send structured tuples back
and forth, using erl_interface is a very good option.
On the other hand, if the messages are simple such as:

<<Op:8, Key:16, Data/binary>>

or some such, it may be a lot easier (and more efficent)
to roll your own. Write all code first so that it works
nice and fine through the spawn driver, i.e, don't link
in the driver until the program works. Once it works, you
make a driver out of it. 


I've used both methods.



/klacke



-- 
Claes Wikstrom                        -- Caps lock is nowhere and
http://www.hyber.org                  -- everything is under control





More information about the erlang-questions mailing list