In the previous section, we learned about MSMQ Message Queuing technology in network distributed programming. In this section, we will learn about another important technology of distributed programming. Net Remoting, the structure of the article or first discuss the basic concepts, and then discuss the specific technical realization, hope to communicate with you and learn.
. Net Remoting technology, which we can consider as a distributed approach. As a mechanism for communication between applications,. Net remoting, unlike MSMQ Message Queuing, does not support offline offline messaging and is suitable only for. NET platform Program Communication. From Microsoft's product point of view, it can be said that Remoting is a distributed component DCOM upgrade, it improves a lot of features, and excellent integration into the. NET platform.. NET Remoting Provides a framework that allows an object to interact with another object through an application domain. That's why we use Remoting. Why, then? In the Windows operating system, the application is separated into a separate process. This process forms a boundary around the application code and data. If the interprocess communication IPC (Internet process Connection) mechanism is not used, code executed in one process cannot access another process. This is an operating system protection mechanism for the application. In some cases, however, we need to cross the application domain and communicate with another application domain, that is, across boundaries (refer to MSDN).
The. Net Remoting communication architecture is shown in the following illustration.
We can briefly understand the communication framework of the. Net remoting by using the figure above, and now let's introduce some of the more important concepts involved:
1. Channel (channel),
In. Net remoting, the communication of objects between two application domains is achieved through a channel (channel). First, the client passes through the remoting, accesses the channel to obtain the server object, and then resolves the client object through the proxy. This provides the possibility of publishing server objects in a service manner. Remote object code can run on the server (such as server-activated objects and client-activated objects), then the client then connects to the server via remoting, obtains the service object, and runs it through serialization on the client.
There are 4 kinds of channels (channel), which are said to have 2-3 kinds of information. There should be 4 species. Httpchanel and Tcpchanel.
(1) HttpChannel. You can use this channel when you are hosting a remote object in asp.net. This channel uses the HTTP protocol to send messages between the client and the server. You can use the encryption mechanism in the HTTP protocol. The host name and port number are required.
(2) TcpChannel. When a remote object resides in an operating system service or other executable file, the channel uses a TCP socket to send messages between the client and the server. The host name and port number are also required. does not provide any built-in security features.
(3) Ipcchanel, inter-process channels, only use the same system, the process of the communication. No host name and port number is required.
(4) Custom channel. A custom transport channel can communicate by using any basic transport protocol udp\smtp\ipx\ Message Queuing mechanism. Users can customize the protocol as needed, so. Net Remoting is more flexible than other mechanisms. does not provide any built-in security features.
2. Remote Objects (Obeject)
The object to be passed in the remoting, in addition to the type and port number of the channel, the designer does not need to know the format of the packet. However, it is important to note that when the client obtains the server-side object, it does not obtain the actual service-side object, but rather obtains its reference through the proxy. Remote objects are inherited from the MarshalByRefObject class, which enables remote objects to be used in remoting application communications and supports Cross-domain boundary access for objects.