-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chapter 3 - Calling get_count #4
Comments
A drawback of the simplistic way it's implemented is that the get_count()
On Mon, Jun 16, 2014 at 10:09 PM, Milton Inostroza Aguilera <
|
Hi Richard, Thanks for your reply! I thought when you were returning from the init function, you were making a timeout: init([Port]) ->
{ok, LSock} = gen_tcp:listen(Port, [{active, true}]),
{ok, #state{port = Port, lsock = LSock}, 0}. So this timeout causes that the following code get executed: handle_info(timeout, #state{lsock = LSock} = State) ->
{ok, _Sock} = gen_tcp:accept(LSock),
{noreply, State}. So when you say: the get_count() function cannot be used until the server has accepted a connection. That means we are blocked waiting for Anyway, now I got the
Thanks. |
@richcarl Thank you for the explanation. |
Hi,
I'm following this book chapter by chapter, and so far I have enjoyed it a lot!. However, now I'm struggling with the
get_count
function. It seems that is not possible to calltr_server:get_count().
from telnet because this will cause a deadlock on the server side:This makes sense to me, because
handle_info
is performing a call totr_server:get_count()
that performs a sync call to the server.The thing that I don't understand is why when I'm calling
get_count
from the erlang console I get the same error:The thing that makes more sad is the fact of why we define a
get_count
function if we cannot use it at all.It would be great if you could help to understand this issue. I'm using the exact file from the repo, so I'm not introducing any noise.
Thanks,
The text was updated successfully, but these errors were encountered: