[erlang-questions] Simple OTP Question...

Edwin Fine erlang-questions_efine@REDACTED
Wed Oct 1 05:27:40 CEST 2008


You're calling gen_server:start() with the wrong arguments. This may help:

25> c(ping).
./ping.erl:7: Warning: variable 'Args' is unused
./ping.erl:10: Warning: variable 'From' is unused
./ping.erl:10: Warning: variable 'Request' is unused
./ping.erl:14: Warning: variable 'Request' is unused
./ping.erl:17: Warning: variable 'Info' is unused
./ping.erl:20: Warning: variable 'Reason' is unused
./ping.erl:20: Warning: variable 'State' is unused
./ping.erl:23: Warning: variable 'Extra' is unused
./ping.erl:23: Warning: variable 'OldVsn' is unused
{ok,ping}
26> {ok, Pid} = gen_server:start({local, myserver}, ping, [], []).
{ok,<0.97.0>}
27> gen_server:call(myserver, some_request).
"Pong"
28> gen_server:call(myserver, {arbitrarily_complex,[some_request]}).
"Pong"
29> exit(Pid,normal).
true
30> erlang:is_process_alive(Pid).
true
31> exit(Pid,shutdown).
true
32> erlang:is_process_alive(Pid).
false
33> f(Pid).
ok
34> {ok, Pid} = gen_server:start(ping, [], []).
{ok,<0.106.0>}
35> gen_server:call(Pid, some_request).
"Pong"
36> exit(Pid,shutdown).
true


On Tue, Sep 30, 2008 at 10:58 PM, David Lloyd <lloy0076@REDACTED> wrote:

>
> Hi There,
>
> My source is:
>
> -module(ping).
> -behaviour(gen_server).
>
> -export([init/1, terminate/2, code_change/3]).
> -export([handle_call/3, handle_cast/2, handle_info/2]).
>
> init(Args) ->
>     {ok, "Started"}.
>
> handle_call(Request, From, State) ->
>     true,
>     {reply, "Pong", State}.
>
> handle_cast(Request, State) ->
>     {stop, "Not implemented", State}.
>
> handle_info(Info, State) ->
>     {stop, "Not implemented", State}.
>
> terminate(Reason, State) ->
>     true.
>
> code_change(OldVsn, State, Extra) ->
>     State.
>
>
> bash-3.00$ erl
> Erlang (BEAM) emulator version 5.5.5 [source] [async-threads:0]
> [kernel-poll:false]
>
> Eshell V5.5.5  (abort with ^G)
> 1> c(ping).
> ./ping.erl:7: Warning: variable 'Args' is unused
> ./ping.erl:10: Warning: variable 'From' is unused
> ./ping.erl:10: Warning: variable 'Request' is unused
> ./ping.erl:14: Warning: variable 'Request' is unused
> ./ping.erl:17: Warning: variable 'Info' is unused
> ./ping.erl:20: Warning: variable 'Reason' is unused
> ./ping.erl:20: Warning: variable 'State' is unused
> ./ping.erl:23: Warning: variable 'Extra' is unused
> ./ping.erl:23: Warning: variable 'OldVsn' is unused
> {ok,ping}
> 2> gen_server:start({ok, pserv}, ping, {args}, []).
>
> =ERROR REPORT==== 1-Oct-2008::12:23:47 ===
> Error in process <0.30.0> with exit value:
>
> {function_clause,[{gen,where,[{ok,pserv}]},{gen,start,6},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]}
>
> ** exited: {undef,[{shell_default,handle_call,[1,2,3]},
>                    {erl_eval,do_apply,5},
>                    {shell,exprs,6},
>                    {shell,eval_loop,3}]} **
>
> However, if I remove the "true, " in the source, the gen_server starts.
>
> I can't figure out what's causing this behaviour and I'm looking at the
> STDLIB documents and Programming Erlan.
>
> DSL
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080930/f542e362/attachment.htm>


More information about the erlang-questions mailing list