在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
erlang调用ruby
ruby调用erlang
安装 gem install rinterface
注意: 节点名必须是sname
示例代码 ruby的 require 'rinterface' r = Erlang::Node.rpc("math","math_server","add",[10,20]) if r[0] == :badrpc puts "Got and Error. Reason #{r[1]}" else puts "Success: #{r[1]}" end
erlang的 -module(math_server). -export([start/0,add/2]). start() -> register(?MODULE,spawn(fun() -> loop() end)). add(X,Y) -> ?MODULE ! {self(),add,X,Y}, receive {?MODULE,Response} -> Response end. loop() -> receive {From,add,X,Y} -> error_logger:info_msg("Got the request, and doing the add...~n"), Sum = X+Y, From ! {?MODULE,Sum}, loop(); Any -> error_logger:info_msg("Got a crazy msg: ~p~n",[Any]), loop() end. 亲测可用 |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论