From 5ef51b5a6dd4d346b34d5c25c8fa9864b016728c Mon Sep 17 00:00:00 2001 From: Marco Ziener Date: Tue, 12 Oct 2010 10:13:08 +0200 Subject: RPCServer --- remote.erl | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 remote.erl (limited to 'remote.erl') diff --git a/remote.erl b/remote.erl new file mode 100644 index 0000000..d3cf88a --- /dev/null +++ b/remote.erl @@ -0,0 +1,23 @@ +-module(remote). +-export([start/0, calculate/1]). + +rpc(C) -> + rechner!{self, C}, + receive + {rechner, Reply} -> + Reply + end. + +loop() -> + receive + {From, {calculate, String}} -> + From ! {rechner, {calculate, calculate(String)}}, + loop() + end. + +start() -> + register(rechner, spawn(fun () -> loop() end)). + +calculate(String) -> + calc:eval(String). + -- cgit v1.2.3