How do I use handle_cast and handle_call in Erlang gen_server?
<p>As far as I understand, I should use <code>handle_cast</code> for asynchronous requests, by sending messages, then react to response via <code>receive..end</code> on client side.</p>

<p>Here is an example:</p>

<pre><code>Pid ! {auth_user, {User, Password}}.
</code></pre>

<p>For synchronous requests, when I want to wait when <code>gen_server</code> sends a response, I must explicitly call the respective function from the module like this:</p>

<pre><code>{ok, Result} = auth_server:auth_user({User, Password}).
</code></pre>

<p>Are the statements from above are correct? </p>

<p>If the latter is correct, why then I need a construction like this if I already have an exported function <code>auth_user</code>?</p>

<pre><code>handle_call({authenticate_user, {Login, Password}}, _From, _) -&gt;
    {reply, {}, {}}.
</code></pre>