⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 helloserver.cs

📁 Professional C# 2nd Edition
💻 CS
字号:
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Remoting.Channels.Http;

namespace Wrox.ProfessionalCSharp
{
	/// <summary>
	/// Summary description for Class1.
	/// </summary>
	class HelloServer
	{
		protected static void ShowChannelProperties(IChannelReceiver channel)
		{
			Console.WriteLine("Name: " + channel.ChannelName);
			Console.WriteLine("Priority: " + channel.ChannelPriority);

			if (channel is HttpChannel)
			{
				HttpChannel httpChannel = channel as HttpChannel;
				Console.WriteLine("Scheme: " + httpChannel.ChannelScheme);
			}

			ChannelDataStore data = (ChannelDataStore)channel.ChannelData;
			foreach (string uri in data.ChannelUris)
			{
				Console.WriteLine("URI: " + uri);
			}
			Console.WriteLine();
		}

		public static void Main(string[] args)
		{
			TcpServerChannel tcpChannel = new TcpServerChannel(8086);

			ShowChannelProperties(tcpChannel);

			HttpServerChannel httpChannel = new HttpServerChannel(8085);

			ShowChannelProperties(httpChannel);

			ChannelServices.RegisterChannel(tcpChannel);
			ChannelServices.RegisterChannel(httpChannel);

			Console.WriteLine(RemotingConfiguration.ApplicationName);
			RemotingConfiguration.ApplicationName = "HelloServer";

			RemotingConfiguration.RegisterActivatedServiceType(
				typeof(Hello));

			System.Console.WriteLine("hit to exit");
			System.Console.ReadLine();
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -