sources:
Client.cs (1.3k)


website:
more info here
studies/corba/Corba-Code7/Client/Client.cs
download file

  1 // ////////////////////////////////////////////////////////
  2 // Lecture on the CORBA Component Model, summer term 2003
  3 // Assignment 7, Stephan Brumme, 702544
  4 //
  5 // Microsoft .NET client that calls a remote "reverse" operation
  6 //
  7
  8 // for console output
  9 using System;
 10
 11 // remoting
 12 using System.Runtime.Remoting;
 13 using System.Runtime.Remoting.Channels;
 14 using System.Runtime.Remoting.Channels.Tcp;
 15
 16 // reverse operation
 17 using ReverseAPI;
 18
 19
 20 namespace Aufgabe7
 21 {
 22     /// <summary>
 23     /// Encapsulates the Main method
 24     /// </summary>
 25     class Client
 26     {
 27         static void Main()
 28         {
 29             // catch any RemoteException
 30             try
 31             {
 32                 // request an available TCP based channel
 33                 ChannelServices.RegisterChannel(new TcpClientChannel());
 34
 35                 // create a proxy for the remote object
 36                 Reverser proxy = (Reverser)Activator.GetObject(typeof(Reverser), "tcp://localhost:8421/ReverserServer");
 37
 38                 // failed ?
 39                 if (proxy == null)
 40                 {
 41                     Console.WriteLine("Invalid reference.");
 42                     return;
 43                 }
 44
 45                 // actually invoke the proxy
 46                 Console.WriteLine("Reversing the string \"Microsoft .NET\": \"" + proxy.reverse("Microsoft .NET") + "\"");
 47             }
 48             catch (RemotingException)
 49             {
 50                 // something went wrongs
 51                 Console.WriteLine("Server not found.");
 52             }
 53         }
 54     }
 55 }
 56