Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C libraries for parsing Erlang binaries?

Tags:

c

erlang

I have an erlang server that will be communicating via tcp sockets with a client written in C. Are there any C libraries for parsing erlang binary terms to C structs?

I realize this is not absolutely necessary, but it would be very convenient.

like image 539
soundly_typed Avatar asked Jan 29 '26 04:01

soundly_typed


2 Answers

There are C libraries for interprocess communication between Erlang and C, erl_interface and C Nodes:

  • http://erlang.org/doc/tutorial/overview.html
  • http://erlang.org/doc/tutorial/erl_interface.html
like image 88
Thilo Avatar answered Jan 31 '26 20:01

Thilo


I've crafted my own: EPAPI (Erlang Port API) in C/C++. Very easy to use and I provide a Debian repo for easy updates.

Example

 PktHandler *ph = new PktHandler();
 MsgHandler *mh = new MsgHandler(ph);

 //Register a message type
 // {echo, {Counter}}
 mh->registerType(1, "echo", "l" );

 //Wait for a message
 Msg *m;
 result = mh->rx(&m);

 //Verify return code
 if (result) {
    //handle error
    printf("ERROR, message: %s", mh->strerror());
    // ...
 }
like image 43
jldupont Avatar answered Jan 31 '26 20:01

jldupont



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!