[erlang-questions] Accessing a gen_server function from another process

code wiget codewiget95@REDACTED
Fri Jul 28 00:09:05 CEST 2017


I am learning about gen_servers right now and I am confused on what I should do about calling a gen_server function that requires a pid.

Generally, gen_server:start_link returns a tuple of the form {ok, Pid}, where Pid is used for API calls to the server. Now, Erlang doesn’t have any good way of storing state, such as a variable to hold this Pid. So, If I have a function that every once in a while needs to call this API, but that API needs a Pid, and theres no way to get a Pid without starting a whole new server… how is this done?

I am sure the answer is not too complex, I greatly appreciate your replies as I am just learning Erlang(on ch 14 of Learn you some Erlang for Great Good).

More information about the erlang-questions mailing list