Server.cs
上传用户:yiyuerguo
上传日期:2014-09-27
资源大小:3781k
文件大小:1k
源码类别:

C#编程

开发平台:

Others

  1. using System;
  2. using System.Runtime.Remoting;
  3. using System.Runtime.Remoting.Channels;
  4. using System.Runtime.Remoting.Channels.Http;
  5. namespace MathServer
  6. {
  7.    class ServerMain
  8.    {
  9.       static void Main(string[] args)
  10.       {
  11.          // Create a channel specifying the port #
  12.          HttpChannel channel = new HttpChannel(13101);
  13.          // Register the channel with the runtime remoting services
  14.          ChannelServices.RegisterChannel(channel);
  15.          // Register a type as a well known type
  16.          RemotingConfiguration.RegisterWellKnownServiceType(
  17.             typeof(MathLibrary.SimpleMath), // The type to register
  18.             "MyURI.soap",                   // The well known name
  19.             WellKnownObjectMode.Singleton   // SingleCall or Singleton
  20.             );
  21.          // Keep the server alive until enter is pressed.
  22.          Console.WriteLine("Server started. Press Enter to end");
  23.          Console.ReadLine();
  24.       }
  25.    }
  26. }