PageRenderTime 65ms CodeModel.GetById 29ms RepoModel.GetById 1ms app.codeStats 1ms

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

https://github.com/gebi/jungerl
C# | 70 lines | 56 code | 14 blank | 0 comment | 2 complexity | 2edde07b5494ebe9ad95dda8963f7f0b MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause, AGPL-1.0
  1. using System;
  2. namespace Otp
  3. {
  4. public class Test
  5. {
  6. static public void Main(String[] args)
  7. {
  8. Erlang.Object obj = Erlang.Object.Format("{a, b, 10, 2.0}");
  9. OtpTrace.TraceEvent("Otp test...");
  10. if (args.Length < 1)
  11. {
  12. OtpTrace.TraceEvent("Usage: Otp sname\n where sname is"+
  13. "the short name of the Erlang node");
  14. return;
  15. }
  16. String host = System.Net.Dns.GetHostName();
  17. String remote = args[0]+"@"+host;
  18. OtpNode node = new OtpNode("q@"+host);
  19. OtpTrace.TraceEvent("This node is called {0} and is using cookie='{1}'.",
  20. node.node(), node.cookie());
  21. bool ok=false;
  22. ok = node.ping(remote, 1000);
  23. if (ok)
  24. OtpTrace.TraceEvent(" successfully pinged node "+remote+"\n");
  25. else
  26. OtpTrace.TraceEvent(" could not ping node "+remote+"\n");
  27. OtpMbox mbox = null;
  28. try
  29. {
  30. mbox = node.createMbox();
  31. Erlang.Object[] rpc = new Erlang.Object[2];
  32. Erlang.Object[] call = new Erlang.Object[5];
  33. call[0] = new Erlang.Atom("call");
  34. call[1] = new Erlang.Atom("lists");
  35. call[2] = new Erlang.Atom("reverse");
  36. call[3] = new Erlang.List(new Erlang.List("Hello Erlang world!"));
  37. call[4] = mbox.self();
  38. rpc[0] = mbox.self();
  39. rpc[1] = new Erlang.Tuple(call);
  40. Erlang.Tuple rpcTuple = new Erlang.Tuple(rpc);
  41. OtpTrace.TraceEvent("=> "+rpcTuple.ToString());
  42. mbox.send("rex", remote, rpcTuple);
  43. Erlang.Object reply = mbox.receive(1000);
  44. OtpTrace.TraceEvent("<= "+reply.ToString());
  45. }
  46. catch (System.Exception)
  47. {
  48. }
  49. finally
  50. {
  51. node.closeMbox(mbox);
  52. }
  53. node.close();
  54. }
  55. }
  56. }