[erlang-questions] erlang-questions Digest, Vol 11, Issue 52

wenew zhang wenewboy@REDACTED
Thu Apr 17 12:39:30 CEST 2008


>>Wher you can specify in ServerName which node the server should be
started.
gen_server:start/start_link(ServerName,..) only have two options:
{local,Name}| {global,GlobalName},

in my project,
i want communicate between two process cross nodes without use global
option,
if can't do that,i think i must use a global mid- transfer the message
like this:pid1---->global Server->pid2
             Pid2---->global server ->Pid1
but i think pid1->Pid2 more faster than above!

any suggestion is very appreciate

Best Regards
wenew Zhang


2008/4/17, erlang-questions-request@REDACTED <
erlang-questions-request@REDACTED>:
>
> Send erlang-questions mailing list submissions to
>         erlang-questions@REDACTED
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         http://www.erlang.org/mailman/listinfo/erlang-questions
> or, via email, send a message with subject or body 'help' to
>         erlang-questions-request@REDACTED
>
> You can reach the person managing the list at
>         erlang-questions-owner@REDACTED
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of erlang-questions digest..."
>
>
> Today's Topics:
>
>    1. Re: :  :  Broken ipv6 behavior? (Raimo Niskanen)
>    2. Re: How to call a locally Pid cross node on       Distributed
>       Application! (Andreas Hillqvist)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 17 Apr 2008 11:48:33 +0200
> From: Raimo Niskanen <raimo+erlang-questions@REDACTED<raimo%2Berlang-questions@REDACTED>
> >
> Subject: Re: [erlang-questions] :  :  Broken ipv6 behavior?
> To: Matthew Dempsky <matthew@REDACTED>, erlang-questions@REDACTED
> Message-ID: <20080417094833.GC27385@REDACTED>
> Content-Type: text/plain; charset=us-ascii
>
> On Thu, Apr 17, 2008 at 01:18:06AM -0700, Matthew Dempsky wrote:
> > On Thu, Apr 17, 2008 at 1:03 AM, Raimo Niskanen
> > <raimo+erlang-questions@REDACTED<raimo%2Berlang-questions@REDACTED>>
> wrote:
> > >  That patch uses gethostbyname2, which is just as or even more
> obsoleted
> > >  than getipnodebyname. I wonder when I (finally) have added
> > >  getaddrinfo support if there is need for gethostbyname2 support too?
> >
> > I tested that patch because the author suggested it worked for him on
> > Linux, and it's a relatively non-intrusive change.  (I don't
> > particularly care what functions are used for IPv6 support as long as
> > they work.)
> >
>
> I am working on getaddrinfo support. When it seems to work I will publish
> a source patch for OTP_R12B-2 and then start on the test cases,
> to get feedback for a final version.
>
> > >  It is strange getipnodebyname works so differently from
> gethostbyname2
> > >  on OS X. They should do the same job.
> >
> > Yeah.
> >
> > >  The flags to getipnodebyname
> > >  are (AF_V4MAPPED | AI_ADDRINFO), which means that it should return
> > >  mapped v4 addresses only if no IPv6 addresses are found and
> > >  that it should return IPv6 addresses only if the machine runs
> > >  IPv6 ("Only if IPv6 configured" according to Solaris 10 headers,
> > >  "Only if there is an interface on the host that is not a loopback
> > >  interface that has an IPv6 address" according to Steven's
> > >  Unix Network Programming).
> >
> > On OS X, AI_DEFAULT is defined to (AI_V4MAPPED_CFG | AI_ADDRCONFIG).
> >
> > I tested various a few different flags options, and ipv6.google.com
> > would only resolve when AI_V4MAPPED(_CFG) was *not* set.  0 and
> > AI_ADDRCONFIG both returned an IPv6 hostent structure.
> >
>
> The header files on MacOS X 10.5.2 says:
> #define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel
> supports */
>
> Would that indicate that the kernel does not support
> mapped IPv4 addresses or what does it not support?
>
> Is this a MacOS X support question?
>
> Or just wait for the getaddrinfo patch and see if it works better.
>
> > >  So maybe gethostbyname2 returns IPv6 records even though your
> > >  machine has no external IPv6 interface?
> >
> > No, every test I have run regarding Erlang and IPv6 in this thread has
> > involved a machine with a globally routable IPv6 address configured.
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://www.erlang.org/mailman/listinfo/erlang-questions
>
> --
>
> / Raimo Niskanen, Erlang/OTP, Ericsson AB
>
>
> ------------------------------
>
> Message: 2
> Date: Thu, 17 Apr 2008 11:53:55 +0200
> From: "Andreas Hillqvist" <andreas.hillqvist@REDACTED>
> Subject: Re: [erlang-questions] How to call a locally Pid cross node
>         on      Distributed Application!
> To: "wenew zhang" <wenewboy@REDACTED>
> Cc: erlang-questions@REDACTED
> Message-ID:
>         <8268eea30804170253r6782999ah8a53f5d5bdded8df@REDACTED>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Now you create two processes on the node. A process that starts the
> gen_server.
>
> You should use gen_server:start_link/4:
>     start_link(ServerName, Module, Args, Options)
> and/or gen_server:start/4:
>     start(ServerName, Module, Args, Options)
> Wher you can specify in ServerName which node the server should be
> started.
>
> If you still want to start the server on the node by spawning a
> process, I guess you will have to somhow return the PID (Is a PID
> local?) from the proess you spawned.
>
> Because the spawn/4 you use:
>    Pid=spawn(authservernode@REDACTED
> ,authserver1,start,[]).
> Returns the spawnde processs. It dose not return the PID to the
> gen_server it starts.
>
>
> Kind regards
> Andreas Hillqvist
>
> 2008/4/17, wenew zhang <wenewboy@REDACTED>:
> > the source code as below,on the first time start the two nodes,i get
> output
> > like this:
> > (socketservernode@REDACTED)2>
> > spawn(authservernode@REDACTED,authserver1,start,[]).
> > <5869.52.0>
> > Authserver start
> > Authserver init with []
> >
> > and then i start i again,
> > (socketservernode@REDACTED)3>
> > Pid=spawn(authservernode@REDACTED
> ,authserver1,start,[]).
> > Authserver start
> > <5869.54.0>
> >
> > No" Authserver init with [] " output  on the Init parts,
> > on the terminate:    io:format("Terminating...~n"),
> > can't find this output,
> > i use rb nether find log-message on the socketservernode no
> authservernode
> >
> > Best Regards
> >
> > Wenew Zhang
> > %%%%%%%%%%%%Begin%%%%%%%%%%%%%%%%%%%%
> >
> > -module(authserver1).
> >
> > -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,start/0]).
> >
> > start_link() ->
> >     io:format("Authserver start_link~n"),
> >     gen_server:start_link({global, ?MODULE}, ?MODULE, [],[]).
> >
> > start() ->
> >     io:format("Authserver start~n"),
> >     gen_server:start({global, ?MODULE}, ?MODULE, [],[]).
> >
> > init([]) ->
> >     process_flag(trap_exit, true),
> >     io:format("Authserver init with []~n"),
> >     {ok,0}.
> >
> >
> >
> > handle_call({213,Uid,Pwd},_From,State) ->
> >     io:format("PLLogin id:~w Uid:~w   Pwd:~w~n",[213,Uid,Pwd]),
> >     {reply,213, State}.
> >
> > handle_cast(_Msg, State) ->
> >     {noreply, State}.
> >
> > handle_info({213,Uid,Pwd},State) ->
> >     io:format("PLLogin id:~w Uid:~w   Pwd:~w~n",[213,Uid,Pwd]),
> >     {noreply, State}.
> >
> > terminate(_Reason, _N) ->
> >     io:format("Terminating...~n"),
> >     ok.
> >
> >
> > code_change(_OldVsn, State, _Extra) ->
> >     {ok, State}.
> > %%%%%%%%%%The end%%%%%%%%%%%%%%%%%%%
> >
> >
> >
> > 2008/4/17, Andreas Hillqvist <andreas.hillqvist@REDACTED>:
> > > It sounds like the process of the PID has died.
> > > How do you start your gen_server?
> > >
> > >
> > > Kind regars
> > > Andreas Hillqvist
> > >
> > > 2008/4/17, wenew zhang <wenewboy@REDACTED>:
> > >
> > > > Yes,it's could create a process and use Pid!{Message} send message,
> > > >
> > > > but i use gen_server behavior  so i want to use
> > > > gen_server:call(Pid,{Message})  to send message,
> > > >
> > > > in my situation, create process successfully,but can't use
> > gen_server:call()
> > > >
> > > > 1.why i get the "exception exit: {noproc," message like below?
> > > > 2.when i use appmon:start() ,i neither find the pid on
> AuthserverNode
> > nor
> > > > SocketServerNode.
> > > >
> > > >
> > > >
> > > > (socketservernode@REDACTED)4>
> > > >
> > Pid=spawn(authservernode@REDACTED
> ,authserver1,start,[]).
> > > > <5805.82.0>
> > > > Authserver start_link
> > > > (socketservernode@REDACTED)5> Pid.
> > > > <5805.82.0>
> > > > (socketservernode@REDACTED)6>
> > > > gen_server:call(Pid,{213,"root","123456"}).
> > > > ** exception exit: {noproc,
> > > >
> > > > {gen_server,call,[<5805.82.0>,{213,"root","123456"}]}}
> > > >      in function  gen_server:call/2
> > > >
> > > >
> > > >
> > > >
> > > > >
> > > > >
> > > > > > thanks for your reply,
> > > > > > i see a example like you said on Joe 's book,
> > > > > > can i use gen_server as a rpc:call()'s Arg ?How can i do that?
> > > > > > tks
> > > > >
> > > > >
> > > > > Sure you can.
> > > > >
> > > > > rpc:call(Node, yourgenserver, start, [Params]).
> > > > >
> > > > >
> > > > > BTW don't top-post and don't forget to CC to erlang-questions :)
> > > > >
> > > > > --
> > > > > With best regards!
> > > > >
> > > >
> > > >
> > >
> > > > _______________________________________________
> > > > 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
>
> End of erlang-questions Digest, Vol 11, Issue 52
> ************************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080417/875c9839/attachment.htm>


More information about the erlang-questions mailing list