程序6.1

    程序6.2

    1. -module(bank_client).
    2. -export([ask/1, deposit/2, withdraw/2]).
    3.  
    4. head_office() -> 'bank@super.eua.ericsson.se'.
    5.  
    6. deposit(Who, Amount) -> call_bank({deposit, Who, Amount}).
    7. withdraw(Who, Amount) -> call_bank({withdraw, Who, Amount}).
    8. call_bank(Msg) ->
    9. Headoffice = head_office(),
    10. monitor_node(Headoffice, true),
    11. receive
    12. {bank_server, Reply} ->
    13. monitor_node(Headoffice, false),
    14. Reply;
    15. {nodedown, Headoffice} ->
    16. end.
    ask(Who) deposit(Who,Amount) withdraw(Who,Amount)

    函数call_bank/1实现了远程过程调用。一旦总行节点停止运作,call_bank/1将会及时发现,并返回no