[erlang-questions] How can i communicate with a gen_server-based server
Andreas Hillqvist
andreas.hillqvist@REDACTED
Fri Mar 28 16:30:35 CET 2008
There are, as you say, issues with using atoms.
An alternativ could be to use binarys, which are more effecintly
stored in dets/menisa than lists, the other alternative to atoms.
If ther is a list_to_atom(String) conversion when verifyin user name
and password, a hacker could exhaust the atoms using bruteforce.
So you should use list_to_existing_atom(String) when verifying
username and password.
A question, ar atoms loaded from a dets when the file is opend?
Storing user name and passwords are stored in a dets table, VM is
started and the file opend, would list_to_existing_atom(String) return
an atom that exist in the dets, and have bot yet been
called/addressed?
Kind regards
Andreas Hillqvist
2008/3/28, orbitz@REDACTED <orbitz@REDACTED>:
> On a complete side topic, but is using atoms for this kind of thing a
> good idea? There are a finite number of atoms that can be held in
> the VM and they are not GC'd right?
>
>
>
> On Mar 28, 2008, at 4:41 AM, Andreas Hillqvist wrote:
> > Early guess, but dose not authserver:start_link() return {ok, PID}?.
> >
> > Try:
> > {ok, Pid} = authserver:start_link().
> > Pid ! {213,'root','12345'}.
> >
> >
> > Kind regards
> > Andreas Hillqvist
> >
> > 2008/3/28, wenew zhang <wenewboy@REDACTED>:
> >> Dear All,
> >>
> >> i use gen_server behavior write a authserver
> >> code:
> >>
> >> -module(authserver).
> >>
> >> -behaviour(gen_server).
> >>
> >> %% gen_server callbacks
> >> -export([init/1, handle_call/3, handle_cast/2, handle_info/2,
> >> terminate/2,
> >> code_change/3]).
> >> -export([start_link/0]).
> >>
> >> -include("protocol.hrl").
> >> start_link() ->
> >> io:format("Authserver start_link~n"),
> >> gen_server:start_link({global, ?MODULE}, ?MODULE, [],[]).
> >>
> >>
> >> init([]) ->
> >> process_flag(trap_exit, true),
> >> io:format("Authserver init with []~n"),
> >> {ok,0}.
> >>
> >> handle_call(Request, _From, State) ->
> >> {stop, {unknown_call, Request}, State}.
> >>
> >>
> >> handle_cast(_Msg, State) ->
> >> {noreply, State}.
> >>
> >>
> >>
> >> handle_info({?PLLOGIN,Uid,Pwd},State) ->
> >> io:format("PLLogin id:~w Uid:~w Pwd:~w~n",[?PLLOGIN,Uid,Pwd]).
> >>
> >> terminate(_Reason, _N) ->
> >> ok.
> >>
> >>
> >> code_change(_OldVsn, State, _Extra) ->
> >> {ok, State}.
> >>
> >> %%___________________end_________________________
> >>
> >>
> >>
> >> handle_info({?PLLOGIN,Uid,Pwd},State) ->
> >> io:format("PLLogin id:~w Uid:~w Pwd:~w~n",[?PLLOGIN,Uid,Pwd]).
> >>
> >> i want call this function above, send ?PLLOGIN},[Uid,Pwd]) from
> >> other node,
> >> and then,authserver send some message back ,
> >> i try:
> >> 2> Pid=authserver:start_link().
> >> Authserver start_link
> >> Authserver init with []
> >> {ok,<0.32.0>}
> >> 3> Pid!{213,'root','12345'}.
> >> ** exception error: bad argument
> >> in operator !/2
> >> called as {ok,<0.32.0>} ! {213,root,'12345'}
> >> 4>
> >>
> >> what can i do?
> >> _______________________________________________
> >> erlang-questions mailing list
> >> erlang-questions@REDACTED
> >> http://www.erlang.org/mailman/listinfo/erlang-questions
> >>
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://www.erlang.org/mailman/listinfo/erlang-questions
>
>
More information about the erlang-questions
mailing list