程序6.1
程序6.2
ask(Who) deposit(Who,Amount) withdraw(Who,Amount)
- -module(bank_client).
- -export([ask/1, deposit/2, withdraw/2]).
- head_office() -> 'bank@super.eua.ericsson.se'.
- deposit(Who, Amount) -> call_bank({deposit, Who, Amount}).
- withdraw(Who, Amount) -> call_bank({withdraw, Who, Amount}).
- call_bank(Msg) ->
- Headoffice = head_office(),
- monitor_node(Headoffice, true),
- receive
- {bank_server, Reply} ->
- monitor_node(Headoffice, false),
- Reply;
- {nodedown, Headoffice} ->
- end.
函数call_bank/1实现了远程过程调用。一旦总行节点停止运作,call_bank/1将会及时发现,并返回no。