jungerl /lib/otp.net/Otp/Test.cs

Language C# Lines 71
MD5 Hash 2edde07b5494ebe9ad95dda8963f7f0b Estimated Cost $1,310 (why?)
Repository https://github.com/gebi/jungerl.git View Raw File View Project SPDX
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;

namespace Otp
{
	public class Test
	{
		static public void Main(String[] args)
		{
            Erlang.Object obj = Erlang.Object.Format("{a, b, 10, 2.0}");

			OtpTrace.TraceEvent("Otp test...");

			if (args.Length < 1)
			{
				OtpTrace.TraceEvent("Usage: Otp sname\n  where sname is"+
					"the short name of the Erlang node");
				return;
			}

			String host = System.Net.Dns.GetHostName();
			String remote = args[0]+"@"+host;

			OtpNode node = new OtpNode("q@"+host);
			OtpTrace.TraceEvent("This node is called {0} and is using cookie='{1}'.",
				node.node(), node.cookie());
			bool ok=false;
			ok = node.ping(remote, 1000);
			if (ok)
				OtpTrace.TraceEvent("   successfully pinged node "+remote+"\n");
			else
				OtpTrace.TraceEvent("   could not ping node "+remote+"\n");

			OtpMbox mbox = null;

			try
			{
				mbox = node.createMbox();

				Erlang.Object[] rpc = new Erlang.Object[2];
				Erlang.Object[] call = new Erlang.Object[5];

				call[0] = new Erlang.Atom("call");
				call[1] = new Erlang.Atom("lists");
				call[2] = new Erlang.Atom("reverse");
				call[3] = new Erlang.List(new Erlang.List("Hello Erlang world!"));
				call[4] = mbox.self();

				rpc[0] = mbox.self();
				rpc[1] = new Erlang.Tuple(call);

				Erlang.Tuple rpcTuple = new Erlang.Tuple(rpc);
				OtpTrace.TraceEvent("=> "+rpcTuple.ToString());

				mbox.send("rex", remote, rpcTuple);
				Erlang.Object reply = mbox.receive(1000);

				OtpTrace.TraceEvent("<= "+reply.ToString());
			}
			catch (System.Exception)
			{
			}
			finally
			{
				node.closeMbox(mbox);
			}

			node.close();
		}
	}
}
Back to Top