Transport Sinks Interface with the Wire

The transport sink knows how to transfer data between itself and its counterpart across the .NET Remoting boundary by using a specific transport protocol. For example, HttpChannel uses a transport sink capable of sending and receiving HTTP requests and responses to transport the serialized message stream data from one .NET Remoting subdivision to another.

A transport sink terminates the client-side channel sink chain. When this sink receives the message stream, it first writes transport protocol header information to the wire and then copies the message stream to the wire, which transports the stream across the .NET Remoting boundary to the server-side .NET Remoting subdivision.

Figure 2-10 shows the server-side channel architecture. As you can see, it's largely the same as the client-side channel architecture.

Channel

Formatter sink

Stream containing serialized message object 1

Channel sink

a ■

Channel sink

Stream containing serialized message object and sink headers 1

Transport sink

-1-

Message object ■ encapsulating the • Foo method call

Transport protocol headers, serialized message object, and sink headers

Message object ■ encapsulating the • Foo method call

Invokes Foo()

Transport protocol headers, serialized message object, and sink headers

Wire

Invokes Foo()

Remote object (marshal-by-reference)

Figure 2-10: Server-side channel architecture

In Figure 2-10, the first sink on the server-side channel sink chain that the serialized message stream encounters is a transport sink that reads the transport protocol headers and the serialized message data from the stream. After pulling this data off the wire, the transport sink passes this information to the next sink in the server-side sink chain. Sinks in the chain perform their processing and pass the resulting message stream and headers up the channel sink chain until they reach the formatter sink. The formatter sink deserializes the message stream and headers into an ¡Message object and passes the message object to the .NET Remoting infrastructure's StackBuilderSink, which actually makes the method call on the remote object. When the method call returns, the StackBuilderSink packages the return result and any output arguments into a message object of type System.Runtime.Remoting.Messaging.ReturnMessage, which the StackBuilderSink then passes back down the sink chain for eventual delivery to the proxy in the caller's .NET Remoting subdivision.

0 0

Post a comment