**** Merged from MCS ****
[mono-project.git] / mcs / class / System.Runtime.Remoting / Test / simple-example.cs
blob0923050ce86c3918d088fb533693521378dc1a6d
1 using System;
2 using System.Threading;
3 using System.Runtime.InteropServices;
4 using System.Runtime.Remoting;
5 using System.Runtime.Remoting.Messaging;
6 using System.Runtime.Remoting.Proxies;
7 using System.Runtime.Remoting.Channels;
8 using System.Runtime.Remoting.Channels.Simple;
9 using System.IO;
12 // compile with:
13 // csc -r:../../lib/System.Runtime.Remoting.dll simple-example.cs
15 class Test : MarshalByRefObject {
17 public int test_function (int a, bool b)
19 Console.WriteLine ("test function called: " + b);
20 return a + 1;
23 static int Main () {
25 Test t1 = new Test ();
26 ObjRef myref = RemotingServices.Marshal (t1, "/test");
27 Console.WriteLine ("OBJREF: " + myref.URI);
29 string url = "simple://localhost:8000/test";
30 string uri;
32 SimpleChannel chnl = new SimpleChannel (8000);
33 ChannelServices.RegisterChannel (chnl);
35 Console.WriteLine ("Channel name: " + chnl.ChannelName);
36 Console.WriteLine ("Channel priority: " + chnl.ChannelPriority);
37 Console.WriteLine ("URI: " + chnl.Parse (url, out uri));
38 Console.WriteLine ("URI: " + uri);
41 Test tp = (Test)RemotingServices.Connect (typeof (Test), url);
43 int res = tp.test_function (4, true);
45 Console.WriteLine ("RESULT: " + res);
47 chnl.StopListening (null);
49 return 0;