Skip to content

Instantly share code, notes, and snippets.

@travisbhartwell
Created February 24, 2017 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save travisbhartwell/d4af2f6c1be8e6533bb75ca3f84bf041 to your computer and use it in GitHub Desktop.
Save travisbhartwell/d4af2f6c1be8e6533bb75ca3f84bf041 to your computer and use it in GitHub Desktop.

First, I started one shell:

erl -sname e1 -setcookie secretcookie

Then, in another terminal, start the second. They have to have different short names (the sname) and the same cookie:

erl -sname e2 -setcookie secretcookie

I made a simple program that listens for a message and responds to it:

accept_data() ->
    receive
        {From, Result} ->
            io:format("Received ~p from ~p.~n", [Result, From]),
            accept_data()
    end.

Then in the e1 shell, I spawn the process and registered it as a name:

register(ad, spawn(complex3, accept_data, [])).

In the e2 shell, I make a call to that like this:

{ad, e1@bashombp} ! {self(), [{foo, 1}, {bar, 2}, {baz, 3}]}.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment