Click here to Skip to main content
13,090,299 members (77,576 online)
Click here to Skip to main content


30 bookmarked
Posted 12 Nov 2008

Remoting Compression Channel Sink

, 12 Nov 2008
An article explaining a Remoting extensible channel sink architecture and an implementation of the compression channel sink.
using System;
using System.Collections;
using System.Runtime.Remoting.Channels;

namespace Util
    public class CompressionServerChannelSinkProvider : IServerChannelSinkProvider
        // The next sink provider in the sink provider chain.
        private IServerChannelSinkProvider _next = null;
        // The compression threshold.
        private readonly int _compressionThreshold;

        public CompressionServerChannelSinkProvider(IDictionary properties, ICollection providerData)
            // read in web.config parameters
            foreach (DictionaryEntry entry in properties)
                switch ((String) entry.Key)
                    case "compressionThreshold":
                        _compressionThreshold = Convert.ToInt32((String) entry.Value);
                        throw new ArgumentException("Invalid configuration entry: " + (String) entry.Key);

        #region IServerChannelSinkProvider Members

        public IServerChannelSink CreateSink(IChannelReceiver channel)
            IServerChannelSink nextSink = null;
            if (_next != null)
                // Call CreateSink on the next sink provider in the chain.  This will return
                // to us the actual next sink object.  If the next sink is null, uh oh!
                if ((nextSink = _next.CreateSink(channel)) == null) return null;

            // Create this sink, passing to it the previous sink in the chain so that it knows
            // to whom messages should be passed.
            return new CompressionServerChannelSink(nextSink, _compressionThreshold);

        public void GetChannelData(IChannelDataStore channelData)
            // Do nothing.  No channel specific data.

        /// <summary>
        /// Gets or sets the next sink provider in the channel sink provider chain.
        /// </summary>
        public IServerChannelSinkProvider Next
			get { return _next; }
			set { _next = value; }


By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

United States United States
Alexander Schmidt. I'm a software developer, who is working primarily with Microsoft technologies including Microsoft .NET. I'm also interested in optimization problems and software engineering in general. You can visit my blog at

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.170813.1 | Last Updated 13 Nov 2008
Article Copyright 2008 by aschmidt
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid