sockets - sending erlang records to a c program -


i working on assignment , part of sending erlang terms c program able communicate each other through established tcp connection.

i able send numbers, lists, boolean, binaries , able decode them in c program sent message. using ei module stuff. on erlang side, encoding using etf term_to_binary/1 , others.

that said, wondering how can send records on socket encoded on erlang side , decoding on c -side. ei has many functions primitives data types decoded binary format not composite 1 records.

records simple -rd(person, {name = "", email = ""}) can send

gen_tcp:send(socket, term_to_binary(#person{name="stack", age = 16})). 

how decode on c-side.

i have googled not lot of resources on this. please help! thank you!

erlang external term format in detail described in documentation. there erlang interface library application contain ei library detailed encoding, decoding , sending erlang terms documentation. note there more low-level interface ei working directly buffers encoded in erlang external term format , erl_interface working eterms equivalent erlang terms internally used in beam vm.

there whole chapter devoted topic in book erlang , otp in action shows practical example using ei scratches surface. official documentation far more detailed , complete. official documentation contains interoperability tutorial user's guide complete examples of working code erl_interface although doesn't contain complete examples of using low-level ei.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -