• λ我爱Aspx >> Asp.Net >> Microsoft .NET Remoting:技术概述(二)
  • Microsoft .NET Remoting:技术概述(二)

  • :aspxer  Դ:internet  :2007-5-15 20:46:07  ؼ:.net
  • 以下我们将举一个使用channel的例子。在这个例子中,我们将可以看到使用HTTP channel把两个应用

    连接在一起是如此的简单。以下的服务器应用提供了一个服务,可将一个字符串的字母顺序反转。

    Server.cs using System;

    using System.IO;

    using System.Runtime.Remoting;

    using System.Runtime.Remoting.Channels.HTTP;

    namespace RemotingSample

    {

    public class Reverser : MarshalByRefObject

    {

    public string Reverse(string text)

    {

    Console.WriteLine("Reverse({0})", text);

    string rev = "";

    for (int i=text.Length-1; i>=0; i--)

    {

    rev += text[i];

    }

    Console.WriteLine("returning : {0}", rev);

    return rev;

    }

    }

    public class TheApp

    {

    public static void Main()

    {

    file:// Create a new HTTP channel that

    // listens on port 8000

    HTTPChannel channel = new HTTPChannel(8000);

    // ReGISter the channel with the runtime

    ChannelServices.ReGISterChannel(channel);

    // Expose the Reverser object from this server

    RemotingServices.RegisterWellKnownType(

    "server", // assembly name

    "RemotingSample.Reverser", // full type name

    "Reverser.soap", file:// URI

    WellKnownObjectMode.Singleton // instancing mode

    );

    // keep the server running until

    // the user presses enter

    Console.WriteLine("Server.exe");

    Console.WriteLine("Press enter to stop server...");

    Ҷƪл˵?
  • һƪ一步一步学Remoting之五:异步操作
    һƪRemoting事件机制续