<!-- generator=" CodePongo (Base on Kukkaisvoima version 15b3TA)" -->
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
>
<channel><title>CodePongo: csharp</title><link>http://codepongo.com/blog</link><description></description><pubDate>Fri, 01 Jun 2018 17:30:06 +0200</pubDate><lastBuildDate>Fri, 01 Jun 2018 17:30:06 +0200</lastBuildDate><generator>http://codepongo.com/blog</generator><language>zh-cn</language><item><title>Comet (programming) 
</title><link>http://codepongo.com/blog/y8txj</link><comments>http://codepongo.com/blog/y8txj#comments</comments><pubDate>Fri, 01 Jun 2018 17:30:06 +0200</pubDate><dc:creator>zuohaitao</dc:creator><category>http</category><category>csharp</category><guid isPermaLink="false">http://codepongo.com/blog/y8txj/</guid><description><![CDATA[ 
 [...]]]></description><content:encoded><![CDATA[
Commet技术，是2000年左右诞生的基于HTTP长连接，服务器向客户端（浏览器）推送数据的一种技术。
目前，websocket技术为此类问题的最优解决方案，C# 也有SignalIR专门用于解决服务器主动向客户端主动推送的问题。




订阅客户端发送订阅请求，发布客户端推送信息，服务器将推送信息转发至订阅客户端
订阅客户端未发起订阅请求，发布客户端推送消息，服务器将消息缓存，带订阅客户端订阅请求到来时转发给订阅客户端
订阅客户端订阅请求超时，仍未有新消息推送，则服务器返回超时


实现


客户端初始化，分配一个缓存消息队列
接收订阅请求后，异步启动遍历消息队列线程循环检查缓存消息队列中是否有消息和是否超时，有消息或超时则返回异步应答订阅请求
发布过程即投递至缓存消息队列中


优化


HTTP 请求和应答采取异步
使用独立线程池或者与http服务器请求应答处理线程公用线程池
消息队列采用NoSQL数据库缓存


参考


comet C#实现

第一部分
第二部分

分享一些Comet开发经验


]]></content:encoded><wfw:commentRss>http://codepongo.com/blog/y8txj/feed/</wfw:commentRss></item><item><title>zlib For .NET
</title><link>http://codepongo.com/blog/3L2EN1</link><comments>http://codepongo.com/blog/3L2EN1#comments</comments><pubDate>Mon, 20 Feb 2017 17:30:06 +0200</pubDate><dc:creator>zuohaitao</dc:creator><category>csharp</category><guid isPermaLink="false">http://codepongo.com/blog/3L2EN1/</guid><description><![CDATA[ 
 [...]]]></description><content:encoded><![CDATA[

using ComponentAce.Compression.Libs.zlib;
namespace zlibdemo
{
    class Program
    {
        static void Main(string[] args)
        {

             {
                 string hizlib = "hi,zlib!";
                 FileStream zip = new FileStream(args[0], System.IO.FileMode.Create);
                 ZOutputStream o = new ZOutputStream(zip, zlibConst.Z_DEFAULT_COMPRESSION);
                 Stream s = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(hizlib));
                 try
                 {

                     {
                         byte[] buffer = new byte[4096];
                         int len;
 0)
                         {
                             output.Write(buffer, 0, len);
                         }
                         output.Flush();
                     };
                     copyStream(s, o);
                 }
                 finally
                 {
                     o.Close();
                     zip.Close();
                     s.Close();
                 }
             };
            inflation();

            {
                FileStream zip = new System.IO.FileStream(args[0], System.IO.FileMode.Open);
                FileStream txt = new System.IO.FileStream(args[1], System.IO.FileMode.Create);
                ZInputStream unzip = new ZInputStream(zip);
                try
                {

                    {
                        byte[] buffer = new byte[4096];
                        int len;
 0)
                        {
                            output.Write(buffer, 0, len);
                        }
                        output.Flush();
                    };
                    copyStream(unzip, txt);
                }
                finally
                {
                    unzip.Close();
                    txt.Close();
                    zip.Close();
                }
            };
            deflation();
        }
    }
}


sample

reference

zlib home site
ZLIB for .NET

]]></content:encoded><wfw:commentRss>http://codepongo.com/blog/3L2EN1/feed/</wfw:commentRss></item></channel></rss>