erlang otp节点间通信
2014-10-13 12:35
246 查看
1.目标:
开启两个节点使得A节点和B节点可以顺利通信
2.步骤与代码:
1)基本操作参看
erlang节点通信小测试
2)代码:
3.具体过程如下图:
test1:
test2:
4.总结:
genserver节点间通信注意进程节点的注册和发送方的发送方式。
开启两个节点使得A节点和B节点可以顺利通信
2.步骤与代码:
1)基本操作参看
erlang节点通信小测试
2)代码:
-module(gentm). -behaviour(gen_server). %%-type my_struct_type() :: 13. -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3, start_link/0]). -record(state, {}). -compile(export_all). -spec test(ArgName1::integer()) -> any(). %% common---------------- start_link() -> gen_server:start_link({local, ?MODULE}, ?MODULE, [], []). init([]) -> {ok, #state{}}. %%-------------------------------------------------------------------- handle_call(Request, _From, State) -> Reply = ok, io:format("get call from ~w, request:~w",[_From,Request]), {reply, Reply, State}. %%-------------------------------------------------------------------- handle_cast(_Msg, State) -> io:format("get cast :~w",[_Msg]), {noreply, State}. %%-------------------------------------------------------------------- handle_info(Info, State) -> io:format("get info :~w",[Info]), {noreply, State}. %%-------------------------------------------------------------------- terminate(_Reason, _State) -> ok. %%-------------------------------------------------------------------- code_change(_OldVsn, State, _Extra) -> {ok, State}. %% common end-------------- test(V)-> io:format("G~w",[V]) . spfun()-> receive {test, V}-> io:format("get testvalue ~w",[V]), spfun(); Other -> io:format("get othervalue ~w quit!",[Other]) end. beginsp()-> Pid = spawn(?MODULE,spfun,[]), register(?MODULE, Pid), put(cpid,Pid), Pid. getfunpid(Node)-> rpc:call(Node, erlang, get, [cpid]).
3.具体过程如下图:
test1:
test2:
4.总结:
genserver节点间通信注意进程节点的注册和发送方的发送方式。
相关文章推荐
- erlang在windows下和虚拟机节点通信
- erlang节点通信小测试
- erlang节点间通信使用erlang send 和使用gen_tcp socket性能的对比(
- erlang局域网内节点通信——艰难四步曲
- erlang局域网内节点通信——艰难四步曲 (转)
- erlang局域网内节点通信——艰难四步曲
- [Erlang]Erlang与Java如何进行节点通信
- [Erlang]Erlang与C的节点通信
- 实验二 串口与节点通信(上)
- 节点通信中被忽略的知识点
- ROS节点与OROCOS组件通信--安装
- Erlang OTP源码分析 – gen_server
- 关于erlang节点显示“*** Terminating erlang”的问题
- mongodb-erlang driver Replica Set Secondary节点分配不均衡的问题
- Erlang中的OTP简介
- erlang OTP gen_fsm 图解分析
- Erlang-多核并发时的树形通信
- erlang OTP中的四大behaviour fsm的例子
- Zigbee 两串口调试助手通过两节点无线通信
- erlang otp 自定义behaviour