So you can call some code on a remote node using the RPC module’s call/4 function, but I think a better method is to use a GenServer process that is registered on both nodes. Then you’ll have a well defined handler to use on either node when you want to transfer data. The function GenServer.call/3 function’s first argument is a server() type. Most examples send pass a pid or name as the first argument, like:
{:ok, _} = GenServer.start_link(Stack, [:hello], name: MyServer)
GenServer.call(MyServer, :message)
However, instead of MyServer, you can pass a tuple of {atom(), node()}. So you can change the call to
GenServer.call({MyServer, :node2}, :message)
replacing :node2 with the name of the other node.


















