Remoting provides a framework that allows an object to interact with another object through an application domain. If you want to communicate through an application domain, the channel is implemented in remoting.
Channel
A channel is an object that passes messages between applications across remoting boundaries (application domains, processes, and between computations). The channel can listen for inbound messages at the endpoint, send outbound messages to the base endpoint, or do both.
The channel must implement the IChannel interface, which provides informational properties, such as: Channelname,channelpriority. The IChannelReceiver interface is used to listen for channel implementations of specific protocols on specific ports. The IChannelSender interface is used to send a message to the channel implementation. Both TcpChannel and HttpChannel objects implement both interfaces and can send or receive messages.
. NET provides several channel implementations:
( 1 ) IpcChannel
Provides high-speed interprocess communication for multi-process applications on the same computer by using named pipes. It performs the functions of:
• Use Named pipes for sender and receiver communication
• Supports encoding in binary format and industry standard SOAP serialization format
• Channeldatastore that generate and use object references
• Support for simulations and delegates
• Supports the use of access control lists (ACLs) on named Pipes to provide advanced access control
IpcChannel is preferred when the application communicates with another application in a native other process.
( 2 ) TcpChannel
The binary formatter serializes all messages into a binary stream and uses the TCP protocol to transmit the stream to the URI, which performs the following functions:
• Use a TCP socket for sender-to-receiver communication
• Supports encoding of load in binary format and industry standard SOAP serialization format
• Channeldatastore that generate and use object references
• Support for simulations and delegates
• Support for SSPI encryption
When HttpChannel connects to a server application domain that listens with TcpChannel, the client receives: the underlying connection has been closed: An exception occurred while receiving an error. There is a problem with channel mismatch.
( 3 ) HttpChannel
Use the SOAP protocol to transfer messages between remote objects. All messages are passed through SoapFormatter, which converts the message to XML and then serializes it, adding a SOAP header to the data stream. If you specify a binary formatter, a binary data stream is created. Finally, the data stream is transmitted to the URI via the HTTP protocol. HttpChannel complies with the soap1.1 standard, which performs the following functions:
• Communication between sender and receiver via HTTP protocol
• Supports encoding load in SOAP and binary format
• Set the receiver to receive HTTP requests through. NET and TCP sockets and send HTTP responses
• Support for simulations and delegates
• Support for SSPI encryption
HttpChannel only a specified number of connections are opened to a given server at a time. The default is 2, which can be set by using the Clientconnectionlimit property.
Applications that use. NET Remoting to communicate across application domain boundaries require an implementation of a remotable class, a listener or host application domain, a client or a calling application domain, The same time segment configures the remoting system in each application domain to use remote activation for remotable types
Remote objects
In order for an object in another application domain to have access to an instance of the class, the class is derived from MarshalByRefObject.
public class Remotabletype:marshalbyrefobject
{}
This class supports remoting applications where objects are accessed across application domain boundaries.
Communicate directly with objects in the same application domain. There are two ways to communicate with objects in different application domains:
• Transfer copies of objects across application domain boundaries
• Exchanging messages through proxies
MarshalByRefObject is the base class for objects that communicate across application domain boundaries by using proxies to exchange messages.
Blog Park Avenue to Jane
http://www.cnblogs.com/jams742003/
. NET Remoting (2)--channel, MarshalByRefObject class