[erlang-questions] gen_server noproc when trying to stop

db <>
Sun Apr 20 16:26:01 CEST 2008


Can someone tell me why can't stop the gen_server?

9> myclnt:start().
{ok,<0.90.0>}
10> myclnt:stop().
** exception exit: {noproc,{gen_server,call,[mysrvr,stop]}}
     in function  gen_server:call/2


-module(myclnt).

-export([
         start/0,
         stop/0
        ]).

-define(SERVER, mysrvr).

start()->
    gen_server:start_link({global, ?SERVER}, ?SERVER, [],[]).

stop()->
    gen_server:call(?SERVER, stop).




-module(mysrvr).

-behaviour(gen_server).

-export([start_link/0]).


-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
         terminate/2, code_change/3]).

-define(SERVER, ?MODULE).

start_link() ->
    gen_server:start_link({global, ?SERVER}, ?MODULE, [], []).

init([]) ->
    {ok,some}.

handle_call({lookup}, _From, State) ->
    Reply = ok,
    io:format("_From: ~p State: ~p ~n",[_From, State]),
    {reply, Reply, State};

handle_call(stop, _From, State)->
    io:format("_From: ~p State: ~p ~n",[_From, State]),
    {stop, normal, stopped, State}.

handle_cast(_Msg, State) ->
    {noreply, State}.

handle_info(_Info, State) ->
    {noreply, State}.

terminate(_Reason, _State) ->
    ok.

code_change(_OldVsn, State, _Extra) ->
    {ok, State}.

Thank you,
-- 
rk

That which we persist in doing becomes easier for us to do; not that
the nature of the thing itself is changed, but that our power to do is
increased.
-Ralph Waldo Emerson



More information about the erlang-questions mailing list