The .NET Remoting system is an architecture that simplifies the communication between objects existing in different application domains. Whether it is not on the same computer. It is very similar to Web Service, but they have two advantages, each is used in different occasions. The .NET Remoting Architecture: The entire architecture is done through an agent, which is that the internal is already made, so it seems that there is no such agent. When the user generates an instance of a remote type, a proxy object is created (in fact, it can also be said to be a COPY of the far end, because the structure of the agent object is similar to the far-ended similar) user Object A method is called and the method is legal, that is, after sending the agent object to the server, after calling the server object, return the result of the client request to the customer agent. It is to help them communicating between the pipeline, mainly to transport data and package-related protocols and send them to the client. This is the whole process. As shown: Return
4
Call server object
6
| -------------------------- ^
| ----------------------- |
|
1
|
|
3 Send to
|
Client
-------------->
Generate a proxy object
-------->
Server
|
|
^
|
|
___ call its method _____
|
__
|
__________________
|
2
5 Return .NET Remoting provides a lot of services: (only to say a few)
1
, Object activation and life cycle control
2
, Responsible for transmitting information from remote applications and transmitting messages to communication pipes for remote applications
3
Pipeline serialization (mainly two: binary and soap) Serialization refers to the state of the object to be converted to the form that can be transmitted. NET remote object can be configured to be three different types:
1
Single Call Object (single call object, my own understanding, huh) This object is called once and then releases it immediately, and does not save the status of this object. When a client method is called, the system creates a new object, which is released, that is, once a call is created again and release.
2
Singleeton Object (single object), all customer requests are used to serve, and only one object is generated to serve multiple requests.
3
, Client
-
ActiVated Object (Customer Activation Object) can be understood as a one-on-one relationship, that is, one request, create an object to serve it, and this way can save the object state. The code below. Net Remoting code:
-------------------------------------------------- --------------------------------------------------
//
Introducing a must-have space, add reference system.Runtime.Remoting and RemoteObject
Using
System;
Using
System.Runtime;
Using
System.Runtime.Remoting;
Using
System.Runtime.Remoting.Channels;
Using
System.Runtime.Remoting.Channels.tcp;
Using
REMOTEOBJECT;
Using
System.IO;
Namespace
Server
{Class ServerClass {static void Main (string [] args) {ChannelServices.RegisterChannel (new TcpServerChannel (9999)); // port listener 9999 RemotingConfiguration.RegisterWellKnownServiceType (typeof (Remote), "Remote", WellKnownObjectMode.SingleCall); / / And registered as a single call type object console.writeLine ("The Channel Has Been Registered!"); Console.readline ();}}} ----------------- -------------------------------------------------- ---------------------------
//
Also import must
Using
System;
Using
System.Runtime;
Using
System.Runtime.Remoting;
Using
System.Runtime.Remoting.Channels;
Using
System.Runtime.Remoting.Channels.tcp;
Using
REMOTEOBJECT;
Namespace
Client
{/ ** // ** // ** ////
-------------------------------------------------- --------------------------------------------
Using
System;
Namespace
REMOTEOBJECT
{Public Class Remote: System.MarshalByrefObject // Inherits MarshalByrefObject makes it a remote object Lic string showdetails () {return "all the details are here";}}
}
-------------------------------------------------- -------------------------------------------