static void Main(string[] args) { TcpChannel channel = new TcpChannel(8086); ChannelServices.RegisterChannel(channel, false); ChannelDataStore data = (ChannelDataStore)channel.ChannelData; foreach (string uri in data.ChannelUris) { Console.WriteLine("The channel URI is {0}.", uri); } RemotingConfiguration.RegisterWellKnownServiceType(typeof(Server), "SuperChat", WellKnownObjectMode.Singleton); string[] urls = channel.GetUrlsForUri("SuperChat"); if (urls.Length > 0) { string objectUrl = urls[0]; string objectUri; string channelUri = channel.Parse(objectUrl, out objectUri); Console.WriteLine("The object URL is {0}.", objectUrl); Console.WriteLine("The object URI is {0}.", objectUri); Console.WriteLine("The channel URI is {0}.", channelUri); } System.Console.WriteLine("<enter> to leave..."); System.Console.ReadLine(); }
public static void Main(string[] args) { //<snippet2> // Create the server channel. TcpChannel serverChannel = new TcpChannel(9090); //</snippet2> // Register the server channel. ChannelServices.RegisterChannel(serverChannel); //<snippet3> // Show the name of the channel. Console.WriteLine("The name of the channel is {0}.", serverChannel.ChannelName); //</snippet3> //<snippet4> // Show the priority of the channel. Console.WriteLine("The priority of the channel is {0}.", serverChannel.ChannelPriority); //</snippet4> //<snippet5> // Show the URIs associated with the channel. ChannelDataStore data = (ChannelDataStore)serverChannel.ChannelData; foreach (string uri in data.ChannelUris) { Console.WriteLine("The channel URI is {0}.", uri); } //</snippet5> // Expose an object for remote calls. RemotingConfiguration.RegisterWellKnownServiceType( typeof(RemoteObject), "RemoteObject.rem", WellKnownObjectMode.Singleton); //<snippet6> // Parse the channel's URI. string[] urls = serverChannel.GetUrlsForUri("RemoteObject.rem"); if (urls.Length > 0) { string objectUrl = urls[0]; string objectUri; string channelUri = serverChannel.Parse(objectUrl, out objectUri); Console.WriteLine("The object URL is {0}.", objectUrl); Console.WriteLine("The object URI is {0}.", objectUri); Console.WriteLine("The channel URI is {0}.", channelUri); } //</snippet6> // Wait for the user prompt. Console.WriteLine("Press ENTER to exit the server."); Console.ReadLine(); }
public static void Main(string[] args) { //<snippet1> // Specify the properties for the server channel. System.Collections.IDictionary dict = new System.Collections.Hashtable(); dict["port"] = 9090; dict["authenticationMode"] = "IdentifyCallers"; // Set up the server channel. TcpChannel serverChannel = new TcpChannel(dict, null, null); ChannelServices.RegisterChannel(serverChannel); //</snippet1> // Show the name and priority of the channel. Console.WriteLine("The name of the channel is {0}.", serverChannel.ChannelName); Console.WriteLine("The priority of the channel is {0}.", serverChannel.ChannelPriority); // Show the URIs associated with the channel. ChannelDataStore data = (ChannelDataStore)serverChannel.ChannelData; foreach (string uri in data.ChannelUris) { Console.WriteLine("The channel URI is {0}.", uri); } // Expose an object for remote calls. RemotingConfiguration.RegisterWellKnownServiceType( typeof(RemoteObject), "RemoteObject.rem", WellKnownObjectMode.Singleton); // Parse the channel's URI. string[] urls = serverChannel.GetUrlsForUri("RemoteObject.rem"); if (urls.Length > 0) { string objectUrl = urls[0]; string objectUri; string channelUri = serverChannel.Parse(objectUrl, out objectUri); Console.WriteLine("The object URL is {0}.", objectUrl); Console.WriteLine("The object URI is {0}.", objectUri); Console.WriteLine("The channel URI is {0}.", channelUri); } // Wait for the user prompt. Console.WriteLine("Press ENTER to exit the server."); Console.ReadLine(); }
[Test] // TcpChannel.Parse () public void ParseURL() { TcpChannel channel; int i; channel = new TcpChannel(); for (i = 0; i < ParseURLTests.Length; i++) { string retval, objectURI; retval = channel.Parse(ParseURLTests[i].input, out objectURI); Assert.AreEqual(ParseURLTests[i].retval, retval, "#C1"); Assert.AreEqual(ParseURLTests[i].objectURI, objectURI, "#C2"); } }
static int Main(string[] argv) { XmlConfigurator.Configure(); //AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; // Get ArchAngel PID from command line arguments if (argv.Length != 2) { Console.WriteLine("This application cannot be run separately from ArchAngel"); return(-1); } ArchAngelPID = Int32.Parse(argv[0]); string uri = argv[1]; // Create an instance of a channel TcpChannel channel = new TcpChannel(0); ChannelServices.RegisterChannel(channel, false); // Register as an available service with the name CommandReceiver // Register as a Singleton so only one runs at a time. RemotingConfiguration.RegisterWellKnownServiceType( typeof(CommandReceiver), "CommandReceiver", WellKnownObjectMode.Singleton); ThreadStart start = SearchForArchAngelProcess; Thread thread = new Thread(start); thread.Start(); DebugProcessInfoService dpis = (DebugProcessInfoService)Activator.GetObject( typeof(DebugProcessInfoService), uri); if (dpis == null) { // ArchAngel is either not running or not responding. The process should die either way. EndDebugProcess.Set(); } else { // Get the URI of our remoting services, so we can tell the ArchAngel // process how to contact us. string objectUri = ""; string[] urls = channel.GetUrlsForUri("CommandReceiver"); if (urls.Length > 0) { string objectUrl = urls[0]; string channelUri = channel.Parse(objectUrl, out objectUri); objectUri = channelUri + objectUri; } if (string.IsNullOrEmpty(objectUri)) { throw new Exception( "The Debug Process could not register itself with .Net" + "remoting. This is a serious error and must be reported to Slyce."); } // Inform ArchAngel that we have started. dpis.Started(objectUri); } // Wait for the signal to end the app. EndDebugProcess.WaitOne(); return(0); }