Skip to content

Instantly share code, notes, and snippets.

@sferik
Forked from anonymous/gist:7324533
Last active December 27, 2015 12:19
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sferik/7324739 to your computer and use it in GitHub Desktop.
Save sferik/7324739 to your computer and use it in GitHub Desktop.
# Node A:
# iex --sname "nodea"
Process.register self, :iex
# Blocking
receive do
{ :hello, pid } ->
IO.puts "Hello from #{inspect(pid)}"
end
# Node B:
# iex --sname "nodeb"
Node.connect :"nodea@myhostname"
# true
parent = self
Node.spawn_link(:"nodea@myhostname", fn ->
parent <- Process.whereis(:iex)
end)
master = receive do
iex_pid -> iex_pid
end
master <- { :hello, "Hello, Batman"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment