How to get the process id of the calling process in erlang?

A looked through http://erlang.org/doc/apps/inets/http_client.html and found the following:

Normal asynchronous request. The result will be sent to the calling process in the form {http, {ReqestId, Result}}

      5 > {ok, RequestId} =
      http:request(get, {"http://www.erlang.org", []}, [], [{sync, false}]).
In this case, the calling process is a shell, so we get the result.

      6 >  receive {http, {RequestId, Result}} -> ok after 500 -> error end.
      ok

http: request sends me a message after calling it this way, but how does it know my process id? As far as I understand, http: request should execute "Pid! {Http, {RequestId, Result}" to send the result to me, but where does it know the value of Pid?

+3
source share
2 answers

#request {} ( httpc_internal.hrl), , . pid; .

http-, , handle_request, from self().

+6

- Pid, ​​ . -

Server ! {self(), arguments}

.

+2

Source: https://habr.com/ru/post/1715245/


All Articles