CHAPTER 18 568 THE .NET (Web design online) REMOTING LAYER

CHAPTER 18 568 THE .NET REMOTING LAYER As you can see, the IMessage interface defines a single property (named Properties) that provides access to a collection used to hold the client-supplied arguments. Once this message object has been populated by the CLR, it is then passed into a closely related type termed the real proxy. The real proxy is the entity that actually passes the message object into the channel (described momentarily). Unlike the transparent proxy, the real proxy can be extended by the programmer and is represented by a base class type named (of course) RealProxy. Again, it is worth pointing out that the CLR will always generate a default implementation of the client-side real proxy, which will serve your needs most (if not all) of the time. Nevertheless, to gain some insight into the functionality provided by the abstract RealProxy base class, ponder the formal definition type: public abstract class RealProxy : object { public virtual ObjRef CreateObjRef(Type requestedType); public virtual bool Equals(object obj); public virtual IntPtr GetCOMIUnknown(bool fIsMarshalled); public virtual int GetHashCode(); public virtual void GetObjectData(SerializationInfo info, StreamingContext context); public Type GetProxiedType(); public static object GetStubData(RealProxy rp); public virtual object GetTransparentProxy(); public Type GetType(); public IConstructionReturnMessage InitializeServerObject( IConstructionCallMessage ctorMsg); public virtual IMessage Invoke(IMessage msg); public virtual void SetCOMIUnknown(IntPtr i); public static void SetStubData(RealProxy rp, object stubData); public virtual IntPtr SupportsInterface(ref Guid iid); public virtual string ToString(); } Unless you are interested in building a custom implementation of the client-side real proxy, the only member of interest is RealProxy.Invoke(). Under the hood, the CLR-generated transparent proxy passes the formatted message object into the RealProxy type via its Invoke() method. Understanding Channels Once the proxies have validated and formatted the client-supplied arguments into a message object, this IMessage-compatible type is passed from the real proxy into a channel object. Channels are the entities in charge of transporting a message to the remote object and, if necessary, ensuring that any member return value is passed from the remote object back to the client. The .NET 2.0 base class libraries provide three channel implementations out of the box: TCP channel HTTP channel IPC channel The TCP channel is represented by the TcpChannel class type and is used to pass messages using the TCP/IP network protocol. TcpChannel is helpful in that the formatted packets are quite lightweight, given that the messages are converted into a tight binary format using a related BinaryFormatter (yes, the same BinaryFormatter you saw in Chapter 17). Use of the TcpChannel type tends to result in faster remote access. The downside is that TCP channels are not firewall-friendly and may require the services of a system administrator to allow messages to pass across machine boundaries.
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.

Leave a Reply