https://github.com/elcritch/c-nodes-example
Simple EI Connect Erlang / Elixir C Node
https://github.com/elcritch/c-nodes-example
Last synced: 3 months ago
JSON representation
Simple EI Connect Erlang / Elixir C Node
- Host: GitHub
- URL: https://github.com/elcritch/c-nodes-example
- Owner: elcritch
- Created: 2020-05-09T05:58:10.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-05-09T06:07:37.000Z (over 5 years ago)
- Last Synced: 2025-06-23T15:11:27.972Z (4 months ago)
- Language: C
- Size: 151 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
c-nodes-example
===============Updated simple Elixir/Erlang C Nodes example. The server `cnode_ei_s2.c` has been updated to utilize the `ei_***` api.
0. Test Elixir C Node server
```shell
shell1$ ./cserver_ei3 3456Connected to e1@127.0.0.1
message: 1
erl_reg_send: msgtype: 6 buff: 0x7fd4ec500010 idx: 42 bufsz: 128
term: ``
bar: 4
tick: 0
``````shell
shell2$ erl -name e1 -setcookie secretcookie
Erlang/OTP 22 [erts-10.6.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]Interactive Elixir (1.9.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(e1@127.0.0.1)1> Node.connect :'cnode@127.0.0.1'
true
iex(e1@127.0.0.1)2> Complex4.bar(4)
4
iex(e1@127.0.0.1)3>
```1. Test C node server example with short node names
```shell
$ ./cserver 3456$ erl -sname e1 -setcookie secretcookie
Erlang/OTP 17 [erts-6.1] [source] [smp:2:2] [async-threads:10] [hipe] [kernel-poll:false]Eshell V6.1 (abort with ^G)
(e1@alpha)1> c(complex3).
{ok,complex3}
(e1@alpha)2> complex3:foo(3).
4
(e1@alpha)3> complex3:bar(5).
10
```2. Test C node server example with long node names
```shell
$ ./cserver2 3456$ erl -name e1 -setcookie secretcookie
Erlang/OTP 17 [erts-6.1] [source] [smp:2:2] [async-threads:10] [hipe] [kernel-poll:false]Eshell V6.1 (abort with ^G)
(e1@alpha.example.com)1> c(complex4).
{ok,complex4}
(e1@alpha.example.com)2> complex4:foo(3).
4
(e1@alpha.example.com)3> complex4:bar(5).
10
```3. Test C node client example
```shell
$ erl -sname e1 -setcookie secretcookie
Erlang/OTP 17 [erts-6.1] [source] [smp:2:2] [async-threads:10] [hipe] [kernel-poll:false]Eshell V6.1 (abort with ^G)
(e1@alpha)1> c(complex3).
{ok,complex3}
```run the C node client
```shell
$ ./cclient
```back to the erlang shell
```shell
(e1@alpha)2> complex3:foo(3).
4
(e1@alpha)3> complex3:bar(5).
10
```