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

Language C# Lines 69
MD5 Hash e1991af279e275511c691d6c2bb0792f Estimated Cost $1,285 (why?)
Repository https://github.com/bmizerany/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
using System;

namespace Otp
{
	public class Test
	{
		static public void Main(String[] args)
		{
			System.Console.Out.WriteLine("Otp test...");

			if (args.Length < 1)
			{
				System.Console.Out.WriteLine("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);
			System.Console.Out.WriteLine("This node is called {0} and is using cookie='{1}'.",
				node.node(), node.cookie());
			bool ok=false;
			ok = node.ping(remote, 1000);
			if (ok)
				System.Console.Out.WriteLine("   successfully pinged node "+remote+"\n");
			else
				System.Console.Out.WriteLine("   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);
				System.Console.Out.WriteLine("=> "+rpcTuple.ToString());

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

				System.Console.Out.WriteLine("<= "+reply.ToString());
			}
			catch (System.Exception)
			{
			}
			finally
			{
				node.closeMbox(mbox);
			}

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