. NET Remoting (1) Simple example

Source: Internet
Author: User

1. Examples (inter-program communication)
    classProgram {Static voidMain (string[] args) {HttpChannel _channel=NewHttpChannel (10001); ChannelServices.RegisterChannel (_channel,false); Console.WriteLine ("HTTP Channel Remoting service start ..."); //method RegisterWellKnownServiceType registers the object type on the server as a known typeRemotingConfiguration.RegisterWellKnownServiceType (typeof(Selfremoteobject),"Selfremoteobject", Wellknownobjectmode.singleton); //server-activated objects have two activation modes: Singleton and SingleCall, which are called known objects and are identified by the enumeration type: WellKnownObjectMode. //the singleton type has only one instance at any one time. All client requests will be serviced by this instance. If there is no instance, the server creates one, and all subsequent client requests are serviced by this instance.            For a single-piece type, it is associated to the default lifetime. //The SingleCall type creates an instance for each client request. The next method call will be serviced by a different server instance, even if the system has not reclaimed a reference to the previous instance. Test ();        Console.read (); }         Public Static voidTest () {//using the Actovator.getobject method to get the proxySelfremoteobject app =(Selfremoteobject) Activator.GetObject (typeof(selfremoteobject),"Http://localhost:10001/selfRemoteObject"); Console.WriteLine (App. Plus (1,3));        Console.ReadLine (); }    }     Public classSelfremoteobject:marshalbyrefobject { Public intPlus (intAintb) {Console.WriteLine ("Client request call: A={0},b={1}", A, b); Console.WriteLine ("calculation result: a+b={0}, returned to the client call", A +b); returnA +b; }    }

. NET Remoting (1) Simple example

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.