4

When deciding one client parameter structure to one OTP gen_server, is it necessary to insert both Pid and Node name into the parameter structure?

Given one remote pid, is it possible to convert pid to node name? I mean full node name, like "emacs@yus-iMac.local".

JMP
  • 4,417
  • 17
  • 30
  • 41
Chen Yu
  • 3,955
  • 1
  • 24
  • 51
  • Does this answer your question? [How do I found out which node an erlang process is running on?](https://stackoverflow.com/questions/7083980/how-do-i-found-out-which-node-an-erlang-process-is-running-on) – 2240 Oct 30 '20 at 13:24

2 Answers2

5

Calling node(Pid) will return the name of the node on which Pid resides.

rvirding
  • 20,848
  • 2
  • 37
  • 56
4

Can someone explain the structure of a Pid in Erlang?

How do I found out which node an erlang process is running on?

Community
  • 1
  • 1
Sergey Miryanov
  • 1,820
  • 16
  • 29
  • On the otp gen_server side, if just receiving remote pid, the server doesn't know the node name. In addition, for writing load balance between nodes, erlang:nodes() return a group of nodes' name, so I need to convert pid to node name. – Chen Yu May 21 '12 at 11:10
  • 3
    erlang:node (Pid) returns atom that is node name. – Sergey Miryanov May 21 '12 at 11:37