Skip to content

Commit a544ebb

Browse files
committed
Introduce erlang distribution
- Add support for handshake from OTP nodes - Add support for monitoring processes and sending messages to registered processes from OTP nodes Signed-off-by: Paul Guyot <pguyot@kallisys.net>
1 parent 2159b25 commit a544ebb

22 files changed

+2128
-17
lines changed

examples/erlang/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ pack_runnable(mqtt_client mqtt_client estdlib eavmlib)
4141
pack_runnable(network_console network_console estdlib eavmlib alisp)
4242
pack_runnable(logging_example logging_example estdlib eavmlib)
4343
pack_runnable(http_client http_client estdlib eavmlib)
44+
pack_runnable(disterl disterl estdlib)

examples/erlang/disterl.erl

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
%
2+
% This file is part of AtomVM.
3+
%
4+
% Copyright 2024 Paul Guyot <pguyot@kallisys.net>
5+
%
6+
% Licensed under the Apache License, Version 2.0 (the "License");
7+
% you may not use this file except in compliance with the License.
8+
% You may obtain a copy of the License at
9+
%
10+
% http://www.apache.org/licenses/LICENSE-2.0
11+
%
12+
% Unless required by applicable law or agreed to in writing, software
13+
% distributed under the License is distributed on an "AS IS" BASIS,
14+
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
% See the License for the specific language governing permissions and
16+
% limitations under the License.
17+
%
18+
% SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
19+
%
20+
21+
-module(disterl).
22+
23+
-export([start/0]).
24+
25+
start() ->
26+
{ok, _KernelPid} = kernel:start(normal, []),
27+
{ok, _NetKernelPid} = net_kernel:start('atomvm@127.0.0.1', #{name_domain => longnames}),
28+
io:format("Distribution was started\n"),
29+
io:format("Node is ~p\n", [node()]),
30+
net_kernel:set_cookie(<<"AtomVM">>),
31+
io:format("Cookie is ~s\n", [net_kernel:get_cookie()]),
32+
register(disterl, self()),
33+
io:format(
34+
"This AtomVM node is waiting for 'quit' message, and this process is registered as 'disterl'\n"
35+
),
36+
io:format("On an OTP node with long names distribution, run:\n"),
37+
io:format("erlang:set_cookie('atomvm@127.0.0.1', 'AtomVM').\n"),
38+
io:format("{disterl, 'atomvm@127.0.0.1'} ! quit.\n"),
39+
receive
40+
quit -> ok
41+
end.

libs/estdlib/src/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ project(estdlib)
2323
include(BuildErlang)
2424

2525
set(ERLANG_MODULES
26+
application
2627
base64
2728
binary
2829
calendar
2930
code
3031
crypto
32+
dist_util
3133
erl_epmd
3234
erts_debug
3335
ets
@@ -41,6 +43,9 @@ set(ERLANG_MODULES
4143
gen_tcp_inet
4244
gen_tcp_socket
4345
supervisor
46+
kernel
47+
net_kernel
48+
net_kernel_sup
4449
inet
4550
io_lib
4651
io
@@ -54,6 +59,8 @@ set(ERLANG_MODULES
5459
queue
5560
sets
5661
socket
62+
socket_dist
63+
socket_dist_controller
5764
ssl
5865
string
5966
timer

0 commit comments

Comments
 (0)