Channels:
Channels are used to physically transport messages to and from the remote objects in client application.
A Channel object listens for incoming messages and sends outbound messages. In both cases, the messages it handle can be made of packets written for a variety of protocols.
There are two primary channels, which are available right now in the .NET framework are the
1) System.Runtime.Remoting.Channels.HTTP
2) System.Runtime.Remoting.Channels.TCP
- HTTP Channels : Transport messages to and from remote objects using the SOAP Protocols.
- TCP Channels : Uses a binary formatter to serialize data to a binary stream & transport it to the target objects using the TCP Protocols.
Channels must implement the IChannel interface, which provides informational properties such as ChannelName and ChannelPriority. Channels designed to listen for a particular protocol on a particular port implement IChannelReceiver and channels designed to send information implement IChannelSender. Both the TcpChannel and HttpChannel objects implement both of these interfaces, so they can be used to send or receive information.
Channel Rules
- At least one channel must be registered with the remoting system on the server before a remote object can be called. Channels must be registered before objects are registered. If a channel is not registered on the client, the remoting system will choose or create one to send outbound calls.
- Channels are registered on a per-application-domain basis. A single process can contain multiple application domains. When a process ends, all channels registered by it are automatically destroyed.
- Channel names must be unique within an application domain. For example, because the default channels have names, to register two HttpChannel objects in one application domain, you must change the names of the channels before registering them.
- You cannot register a channel that listens on a specific port more than once. Even though channels are registered on a per-application-domain basis, different application domains on the same machine cannot register the same channel listening on the same port.
- If you are not sure about whether a port is available, use 0 (zero) when configuring your channel's port and the remoting system will choose an available port for you.
- Clients can communicate with a remote object using any registered channel. The remoting system ensures that the remote object is connected to the right channel when a client attempts to connect to the object. The client is responsible for calling ChannelServices.RegisterChannel before attempting to communicate with a remote object. If it expects a callback function, the client must register a channel and a port.