﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-isware</title><link>http://www.cppblog.com/isware/</link><description /><language>zh-cn</language><lastBuildDate>Tue, 07 Apr 2026 21:19:41 GMT</lastBuildDate><pubDate>Tue, 07 Apr 2026 21:19:41 GMT</pubDate><ttl>60</ttl><item><title>Install Ubuntu from usb disk</title><link>http://www.cppblog.com/isware/archive/2011/09/24/156686.html</link><dc:creator>艾斯维亚</dc:creator><author>艾斯维亚</author><pubDate>Sat, 24 Sep 2011 03:07:00 GMT</pubDate><guid>http://www.cppblog.com/isware/archive/2011/09/24/156686.html</guid><wfw:comment>http://www.cppblog.com/isware/comments/156686.html</wfw:comment><comments>http://www.cppblog.com/isware/archive/2011/09/24/156686.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/isware/comments/commentRss/156686.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/isware/services/trackbacks/156686.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Install Ubuntu from usb disk&nbsp;&nbsp;<a href='http://www.cppblog.com/isware/archive/2011/09/24/156686.html'>阅读全文</a><img src ="http://www.cppblog.com/isware/aggbug/156686.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/isware/" target="_blank">艾斯维亚</a> 2011-09-24 11:07 <a href="http://www.cppblog.com/isware/archive/2011/09/24/156686.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转]为什么社交网站可以挑战搜索引擎</title><link>http://www.cppblog.com/isware/archive/2011/09/22/156511.html</link><dc:creator>艾斯维亚</dc:creator><author>艾斯维亚</author><pubDate>Thu, 22 Sep 2011 02:03:00 GMT</pubDate><guid>http://www.cppblog.com/isware/archive/2011/09/22/156511.html</guid><wfw:comment>http://www.cppblog.com/isware/comments/156511.html</wfw:comment><comments>http://www.cppblog.com/isware/archive/2011/09/22/156511.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/isware/comments/commentRss/156511.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/isware/services/trackbacks/156511.html</trackback:ping><description><![CDATA[<div>　　相关关键词搜索广告能够发展成产值达数十亿美元的行业，自有其道理&#8212;&#8212;因为它非常善于将搜索信息的用户变成想要购物的消费者。但是，并不总是如此。Dropbox 的首席执行官兼创始人Drew Houston近日在斯坦福-Accel讨论会(Stanford Accel Symposium)上的发言提供了又一个例证。在发言中，他讲到Dropbox这样一个云存储公司是如何发展到今天拥有4百多万用户的规模。他介绍说，这样的公司能够获得如此大的用户规模，搜索广告并没有带来很大的帮助，并对其原因进行了描述。<br /><br />　　据Houston所述，Dropbox做了大量工作来以吸引大众的注意力&#8212;&#8212;他们认为这是创业公司需要做的，比如说，聘请公关公司，购买Google关键词搜索广告等，但是这些措施的收效都不明显。他特别说到，就吸引新用户注册这一点来看，搜索广告完全不起作用，因为公司投入了很多钱做广告，往往只能获得一个新用户&#8212;&#8212;远远超过公司可能获得的收费。<br /><br />　　这也是当下经常被人谈论的问题的核心所在，也就是Google如今正面临的来自社会化媒体的挑战，特别是Facebook。Google的搜索广告做得很好，原因是使用搜索的用户已经决定好要买什么，只需要寻找哪儿可以买&#8212;&#8212;这并不适用于那些只想在网络上找人聊天、交朋友的用户。就潜在用户来说，(就像Dropbox一样，因为用户很可能并不知道这个产品可以满足他们生活中的某种需要)，社会化媒体很可能收效更为显著，靠的就是口口相传的互相推荐。<br /><br />　　人们在Google上去哪儿找口碑推荐和相关讨论?答案就是，可能找不到。也许他们能够从Buzz上找到一些，但是，Buzz并不成功。当然，这并不是说Google本身没用，或者说关键词搜索广告毫无价值&#8212;&#8212;即便是Dropbox这种情况，一旦用户听说了它的强大功能，在自己试用之前，很可能会上Google去搜索其他用户的评论，相关产品的信息等等。但是，问题就在于Google不能在社交范围内发挥作用，就像Kevin Kelly在《科技评论》上的文章里说的，有人气的地方才能盈利(Money follows attention)。<br /><br />　　Houston所观察到的现象只是另一个例子，再次说明Google为什么需要当心社会化媒体，以及这意味着什么。同时，这也解释了为什么Google重视将&#8220;社交层&#8221;添加到产品和服务中去 -- 尽管真正的社交型产品并不仅仅等于在现有的功能上添上新组件，这也是Facebook能够在这个领域内大展宏图的原因。不管怎样，Google确实需要找到将社交因素融合到现有服务中去的方法，不然，就将面临失去人气的风险&#8212;&#8212;乃至，损失潜在的收入。</div><img src ="http://www.cppblog.com/isware/aggbug/156511.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/isware/" target="_blank">艾斯维亚</a> 2011-09-22 10:03 <a href="http://www.cppblog.com/isware/archive/2011/09/22/156511.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Adobe AIR</title><link>http://www.cppblog.com/isware/archive/2011/09/14/155747.html</link><dc:creator>艾斯维亚</dc:creator><author>艾斯维亚</author><pubDate>Wed, 14 Sep 2011 05:54:00 GMT</pubDate><guid>http://www.cppblog.com/isware/archive/2011/09/14/155747.html</guid><description><![CDATA[<div>http://baike.baidu.com/view/1167325.htm</div><img src ="http://www.cppblog.com/isware/aggbug/155747.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/isware/" target="_blank">艾斯维亚</a> 2011-09-14 13:54 <a href="http://www.cppblog.com/isware/archive/2011/09/14/155747.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>超级详细Tcpdump 的用法</title><link>http://www.cppblog.com/isware/archive/2011/08/10/152954.html</link><dc:creator>艾斯维亚</dc:creator><author>艾斯维亚</author><pubDate>Wed, 10 Aug 2011 08:04:00 GMT</pubDate><guid>http://www.cppblog.com/isware/archive/2011/08/10/152954.html</guid><wfw:comment>http://www.cppblog.com/isware/comments/152954.html</wfw:comment><comments>http://www.cppblog.com/isware/archive/2011/08/10/152954.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/isware/comments/commentRss/152954.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/isware/services/trackbacks/152954.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 超级详细Tcpdump 的用法&nbsp;&nbsp;<a href='http://www.cppblog.com/isware/archive/2011/08/10/152954.html'>阅读全文</a><img src ="http://www.cppblog.com/isware/aggbug/152954.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/isware/" target="_blank">艾斯维亚</a> 2011-08-10 16:04 <a href="http://www.cppblog.com/isware/archive/2011/08/10/152954.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>gdb core文件调试</title><link>http://www.cppblog.com/isware/archive/2011/07/29/152046.html</link><dc:creator>艾斯维亚</dc:creator><author>艾斯维亚</author><pubDate>Fri, 29 Jul 2011 07:46:00 GMT</pubDate><guid>http://www.cppblog.com/isware/archive/2011/07/29/152046.html</guid><wfw:comment>http://www.cppblog.com/isware/comments/152046.html</wfw:comment><comments>http://www.cppblog.com/isware/archive/2011/07/29/152046.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/isware/comments/commentRss/152046.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/isware/services/trackbacks/152046.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: gdb core debug&nbsp;&nbsp;<a href='http://www.cppblog.com/isware/archive/2011/07/29/152046.html'>阅读全文</a><img src ="http://www.cppblog.com/isware/aggbug/152046.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/isware/" target="_blank">艾斯维亚</a> 2011-07-29 15:46 <a href="http://www.cppblog.com/isware/archive/2011/07/29/152046.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转]零知识证明</title><link>http://www.cppblog.com/isware/archive/2011/07/28/151986.html</link><dc:creator>艾斯维亚</dc:creator><author>艾斯维亚</author><pubDate>Thu, 28 Jul 2011 07:38:00 GMT</pubDate><guid>http://www.cppblog.com/isware/archive/2011/07/28/151986.html</guid><wfw:comment>http://www.cppblog.com/isware/comments/151986.html</wfw:comment><comments>http://www.cppblog.com/isware/archive/2011/07/28/151986.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/isware/comments/commentRss/151986.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/isware/services/trackbacks/151986.html</trackback:ping><description><![CDATA[<div><p>战争中你被俘了，敌人拷问你情报。你是这么想的：如果我把情报都告诉他们，他们就会认为我没有价值了，就会杀了我省粮食，但如果我死活不说，他们也会认为我没有价值而杀了我。怎样才能做到既让他们确信我知道情报，但又一丁点情报也不泄露呢？<br /><br /></p> <p>这的确是一个令人纠结的问题，但阿里巴巴想了一个好办法，当强盗向他拷问打开山洞石门的咒语时，他对强盗说：&#8220;你们离我一箭之地，用弓箭指着我，你们举起右手我就念咒语打开石门，举起左手我就念咒语关上石门，如果我做不到或逃跑，你们就用弓箭射死我。&#8221;</p> <p><br />强盗们当然会同意，因为这个方案不仅对他们没有任何损失，而且还能帮助他们搞清楚阿里巴巴到底是否知道咒语这个问题。阿里巴巴也没损失，因为处于一箭之地的强盗听不到他念的咒语，不必担心泄露了秘密，而且他确信自己的咒语有效，也不会发生被射死的杯具。</p> <p><br />强盗举起了右手，只见阿里巴巴的嘴动了几下，石门果真打开了，强盗举起了左手，阿里巴巴的嘴动了几下后石门又关上了。强盗还是有点不信，说 不准这是巧合呢，他们不断地换着节奏举右手举左手，石门跟着他们的节奏开开关关，最后强盗们想，如果还认为这只是巧合，自己未免是个傻瓜，那还是相信了阿 里巴巴吧。</p> <p><br />&#8220;零知识证明&#8221;说的是示证者向验证者表明他知道某种秘密，不仅能使验证者完全确信他的确知道这个秘密，同时还保证一丁点秘密也不泄露给验证者。阿里巴巴的这个方案，就是认证理论&#8220;零知识证明&#8221;的一个重要协议。</p> <p><br />除了被俘后如何靠情报保命这个问题，零知识证明在社会领域中还有着很多应用场合。例如你证明了一个世界级的数学难题，但在发表出来之前，总 是要找个泰斗级的数学家审稿吧，于是你将证明过程发给了他，他看懂后却动了歪心思，他把你的稿子压住，把你的证明用自己的名义发表，他名利双收，你郁闷至 死，你去告他也没用，因为学术界更相信的是这位泰斗，而不是你这个无名之辈。<br /></p> <p><br />这并不是天方夜谭，而是学术界常见的难题，前些年有个博士生告他的泰斗级导师剽窃他的成果，但除了令师生关系恶化外没有任何效果，最后他使 出了撒手锏，称他在给导师审阅的论文的关键公式中，故意标错了一个下标，而这会导致整个推导失败。学术委员会一查果真如此，但还是有倾向于泰斗的声音，有 人说那是泰斗的笔误，只不过让你发现了而矣，并不能证明那公式就是你推导出来的。</p> <p><br />这个博士生故意标错下标，不能说他没有心眼，但他没有把&#8220;零知识证明&#8221;理论用好，以致于落到这种地步。&#8220;零知识证明&#8221;早在1986年就被 A.Fiat和A.Shamir用数学的方法给出了解决方案，并在同年申请了美国专利，但由于该理论可能被用于军事领域，专利局被军方密令搁置，6个月 后，军方命令：&#8220;该申请发表后会有害于国家安全......所有美国人的研究未经许可而泄露将会被判刑罚款&#8221;。看来军方认为作者肯定是美国人了，但作者实 际上是在美国申请专利的以色列人，研究也是在以色列的大学里做的，军方这个命令摆了个大乌龙，虽然两天后撤消了，但已经成为了学术界的笑柄。</p> <p><br />这个笑柄也说明了一个问题，即&#8220;零知识证明&#8221;非常重要。基于数学的推理虽然非常复杂，但思路却很简单，上述的阿里巴巴方案就是其中之一。其它的一些方案，也都是像这样遵循着分割和选择（Cut and Chose）协议的。</p> <p><br />例如图论中有个哈米尔顿回路（Hamiltonian Cyclic）问题，说的是多个顶点的全连通图，若有一条通路通过了所有顶点，且每个顶点只通过一次，那这就是哈米尔顿回路。如果顶点较多的话，即使用计算机穷举计算很难找出这条回路，因为通路的可能性真在是太多了。</p> <p><br />如果松鼠会贴了一张全连通图（命名为A图）悬赏哈米尔顿回路，而且任命我（奥卡姆剃刀）作为评审官，你幸运的找到了一条，那该怎么办呢，将结果直接发给我吗？千万不要，因为保不齐我会将你的成果让给了我的亲信。那你该怎么办呢？应该这么办：</p> <p><br />1、你将A图的顶点搞乱了，并生成一张新图，只是顶点的位置变了，而新图顶点之间的连线关系与A图是完全一致的。这时，新图中每个顶点与A图中每个顶点的对应关系你是清楚的，而且新图中的哈米尔顿回路你也是知道的。</p> <p><br />2、你将这张新图发给我，没错，就是仅仅一张新图，上面并没有画着你发现的牛B回路。</p> <p><br />3、我收到后，对你提出两个问题中的一个：一是证明新图就是从A图变形过来的，所有顶点和连线的关系完全一致，二是画出新图中的哈米尔顿回路。</p> <p><br />4、如果你真的找到了A图的哈米尔顿回路，这两个问题当然都能轻松回答。需要注意的是：你只需要回答第3步的其中一个问题，千万不要两个问题一并回答，否则我就知道你关于A图的哈米尔顿回路了，你就SB了。</p> <p><br />5、我还是不相信你，因为有可能你只是将A图变了形，却根本不知道A图的哈米尔顿回路，而我在第3步时恰好要求你证明新图就是从A图变形过 来的，你当然能证明。或者有可能你找了个你知道哈米尔顿回路的图，但这张图跟A图一点关系都没有，而我在第3步恰好要求你画出这张图的哈米尔顿回路。</p> <p><br />6、我要求你从第1步开始重复这个验证过程，随着次数的增加，第5步那种巧合的可能性就越来越低，如果你多次能回答对第3步中的问题，那我还不相信你已经找到了A图的哈米尔顿回路，那我就是一个傻瓜。</p> <p><br />7、为了表明我不是傻瓜，我在松鼠会群博里宣布你找到了A图的哈米尔顿回路，而这时我并没有看到你所画的A图的哈米尔顿回路。</p> <p>回到你证明了世界级的数学难题的问题，你可以用这种分割和选择协议来进行零知识证明，来保护你的权利。你公开声称你解决了这个数学难题后，验证者会 给你出一个其它的题，而能做出这道题的前提条件是已经解决了那个数学难题，否则的话无解，而且这个条件是学术界所公认的，这个题就是所谓的平行问题。不出 所料，你靠着已经解开数学难题的基础把这个平行问题做出来了，但验证者还是不信，他又出了一道平行问题，你又做出来了，多次较量后，验证者就确信了你已经 解决了那个数学难题，虽然他并没有看到具体的解法。</p> <p><br />大家已经看出来了，零知识证明需要示证者和验证者的密切配合，但如果你只是一个数学界的无名之辈，即使你宣称你解决了数学难题，也不会有人跟你配合着玩零知识证明，那你该怎么办呢？</p> <br />我告诉你一个可以在法庭上都能当作有效证据的招数，你将证明打印好，选择一个最可靠最权威的邮政公司，把它寄给自己，当你收到这个扣着邮戳 的包裹后，不要打开，把它放好，然后就可以把证明寄给数学泰斗。如果他用自己的名义发表了，不必着急，等他依靠其影响力把这个证明炒热后再出手，你上法庭 控告他，他当然不承认，在法庭上你将那个没开封的包裹拿出来，上面清清楚楚地盖着时间戳，这就证明了你包裹里的证明是发生在那个时间戳之前的，加上之后的 你邮给泰斗论文的邮件存根，和泰斗以自己名义发表论文的时间，三者就构成了一个完整的证据链，泰斗灰头土脸名声扫地，而你大获全胜名利双收。</div><img src ="http://www.cppblog.com/isware/aggbug/151986.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/isware/" target="_blank">艾斯维亚</a> 2011-07-28 15:38 <a href="http://www.cppblog.com/isware/archive/2011/07/28/151986.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>linux多线程及信号处理</title><link>http://www.cppblog.com/isware/archive/2011/07/27/151939.html</link><dc:creator>艾斯维亚</dc:creator><author>艾斯维亚</author><pubDate>Wed, 27 Jul 2011 08:28:00 GMT</pubDate><guid>http://www.cppblog.com/isware/archive/2011/07/27/151939.html</guid><wfw:comment>http://www.cppblog.com/isware/comments/151939.html</wfw:comment><comments>http://www.cppblog.com/isware/archive/2011/07/27/151939.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/isware/comments/commentRss/151939.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/isware/services/trackbacks/151939.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 多线程及信号处理&nbsp;&nbsp;<a href='http://www.cppblog.com/isware/archive/2011/07/27/151939.html'>阅读全文</a><img src ="http://www.cppblog.com/isware/aggbug/151939.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/isware/" target="_blank">艾斯维亚</a> 2011-07-27 16:28 <a href="http://www.cppblog.com/isware/archive/2011/07/27/151939.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>图解安装64-bit Adobe Flash Player</title><link>http://www.cppblog.com/isware/archive/2011/07/25/151778.html</link><dc:creator>艾斯维亚</dc:creator><author>艾斯维亚</author><pubDate>Mon, 25 Jul 2011 03:40:00 GMT</pubDate><guid>http://www.cppblog.com/isware/archive/2011/07/25/151778.html</guid><wfw:comment>http://www.cppblog.com/isware/comments/151778.html</wfw:comment><comments>http://www.cppblog.com/isware/archive/2011/07/25/151778.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/isware/comments/commentRss/151778.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/isware/services/trackbacks/151778.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: ubuntu flashplayer 64bit&nbsp;&nbsp;<a href='http://www.cppblog.com/isware/archive/2011/07/25/151778.html'>阅读全文</a><img src ="http://www.cppblog.com/isware/aggbug/151778.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/isware/" target="_blank">艾斯维亚</a> 2011-07-25 11:40 <a href="http://www.cppblog.com/isware/archive/2011/07/25/151778.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ubuntu C/C++ 开发环境配置</title><link>http://www.cppblog.com/isware/archive/2011/07/25/151775.html</link><dc:creator>艾斯维亚</dc:creator><author>艾斯维亚</author><pubDate>Mon, 25 Jul 2011 02:56:00 GMT</pubDate><guid>http://www.cppblog.com/isware/archive/2011/07/25/151775.html</guid><wfw:comment>http://www.cppblog.com/isware/comments/151775.html</wfw:comment><comments>http://www.cppblog.com/isware/archive/2011/07/25/151775.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/isware/comments/commentRss/151775.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/isware/services/trackbacks/151775.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: ubuntu c/c++开发环境配置（vim）&nbsp;&nbsp;<a href='http://www.cppblog.com/isware/archive/2011/07/25/151775.html'>阅读全文</a><img src ="http://www.cppblog.com/isware/aggbug/151775.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/isware/" target="_blank">艾斯维亚</a> 2011-07-25 10:56 <a href="http://www.cppblog.com/isware/archive/2011/07/25/151775.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转]tcp不能保证数据传输的万无一失</title><link>http://www.cppblog.com/isware/archive/2011/07/21/151548.html</link><dc:creator>艾斯维亚</dc:creator><author>艾斯维亚</author><pubDate>Thu, 21 Jul 2011 07:08:00 GMT</pubDate><guid>http://www.cppblog.com/isware/archive/2011/07/21/151548.html</guid><wfw:comment>http://www.cppblog.com/isware/comments/151548.html</wfw:comment><comments>http://www.cppblog.com/isware/archive/2011/07/21/151548.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/isware/comments/commentRss/151548.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/isware/services/trackbacks/151548.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: TCP 数据传输可靠性&nbsp;&nbsp;<a href='http://www.cppblog.com/isware/archive/2011/07/21/151548.html'>阅读全文</a><img src ="http://www.cppblog.com/isware/aggbug/151548.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/isware/" target="_blank">艾斯维亚</a> 2011-07-21 15:08 <a href="http://www.cppblog.com/isware/archive/2011/07/21/151548.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转]使用sendfile()让数据传输得到最优化</title><link>http://www.cppblog.com/isware/archive/2011/07/21/151547.html</link><dc:creator>艾斯维亚</dc:creator><author>艾斯维亚</author><pubDate>Thu, 21 Jul 2011 06:59:00 GMT</pubDate><guid>http://www.cppblog.com/isware/archive/2011/07/21/151547.html</guid><wfw:comment>http://www.cppblog.com/isware/comments/151547.html</wfw:comment><comments>http://www.cppblog.com/isware/archive/2011/07/21/151547.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/isware/comments/commentRss/151547.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/isware/services/trackbacks/151547.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 网络数据传输优化&nbsp;&nbsp;<a href='http://www.cppblog.com/isware/archive/2011/07/21/151547.html'>阅读全文</a><img src ="http://www.cppblog.com/isware/aggbug/151547.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/isware/" target="_blank">艾斯维亚</a> 2011-07-21 14:59 <a href="http://www.cppblog.com/isware/archive/2011/07/21/151547.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Linux的mmap文件内存映射机制</title><link>http://www.cppblog.com/isware/archive/2011/07/20/151489.html</link><dc:creator>艾斯维亚</dc:creator><author>艾斯维亚</author><pubDate>Wed, 20 Jul 2011 07:51:00 GMT</pubDate><guid>http://www.cppblog.com/isware/archive/2011/07/20/151489.html</guid><wfw:comment>http://www.cppblog.com/isware/comments/151489.html</wfw:comment><comments>http://www.cppblog.com/isware/archive/2011/07/20/151489.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/isware/comments/commentRss/151489.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/isware/services/trackbacks/151489.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Linux的mmap文件内存映射机制&nbsp;&nbsp;<a href='http://www.cppblog.com/isware/archive/2011/07/20/151489.html'>阅读全文</a><img src ="http://www.cppblog.com/isware/aggbug/151489.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/isware/" target="_blank">艾斯维亚</a> 2011-07-20 15:51 <a href="http://www.cppblog.com/isware/archive/2011/07/20/151489.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>惊群问题的思考</title><link>http://www.cppblog.com/isware/archive/2011/07/20/151470.html</link><dc:creator>艾斯维亚</dc:creator><author>艾斯维亚</author><pubDate>Wed, 20 Jul 2011 04:44:00 GMT</pubDate><guid>http://www.cppblog.com/isware/archive/2011/07/20/151470.html</guid><wfw:comment>http://www.cppblog.com/isware/comments/151470.html</wfw:comment><comments>http://www.cppblog.com/isware/archive/2011/07/20/151470.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cppblog.com/isware/comments/commentRss/151470.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/isware/services/trackbacks/151470.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: “据说”惊群问题已经是一个很古老的问题了，并且在大多数系统中已经得到有效解决，但对我来说，仍旧是一个比较新的概念，因此有必要记录一下。&nbsp;&nbsp;<a href='http://www.cppblog.com/isware/archive/2011/07/20/151470.html'>阅读全文</a><img src ="http://www.cppblog.com/isware/aggbug/151470.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/isware/" target="_blank">艾斯维亚</a> 2011-07-20 12:44 <a href="http://www.cppblog.com/isware/archive/2011/07/20/151470.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>High performance server architecture(高性能服务器架构)</title><link>http://www.cppblog.com/isware/archive/2011/07/19/151390.html</link><dc:creator>艾斯维亚</dc:creator><author>艾斯维亚</author><pubDate>Tue, 19 Jul 2011 08:12:00 GMT</pubDate><guid>http://www.cppblog.com/isware/archive/2011/07/19/151390.html</guid><wfw:comment>http://www.cppblog.com/isware/comments/151390.html</wfw:comment><comments>http://www.cppblog.com/isware/archive/2011/07/19/151390.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/isware/comments/commentRss/151390.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/isware/services/trackbacks/151390.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: from: http://pl.atyp.us/content/tech/servers.htmlIntroduction The purpose of this document is to share some ideas that I've  developed over the years about how to develop a certain kind of  applicatio...&nbsp;&nbsp;<a href='http://www.cppblog.com/isware/archive/2011/07/19/151390.html'>阅读全文</a><img src ="http://www.cppblog.com/isware/aggbug/151390.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/isware/" target="_blank">艾斯维亚</a> 2011-07-19 16:12 <a href="http://www.cppblog.com/isware/archive/2011/07/19/151390.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转]libevent介绍</title><link>http://www.cppblog.com/isware/archive/2011/07/19/151383.html</link><dc:creator>艾斯维亚</dc:creator><author>艾斯维亚</author><pubDate>Tue, 19 Jul 2011 07:07:00 GMT</pubDate><guid>http://www.cppblog.com/isware/archive/2011/07/19/151383.html</guid><wfw:comment>http://www.cppblog.com/isware/comments/151383.html</wfw:comment><comments>http://www.cppblog.com/isware/archive/2011/07/19/151383.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/isware/comments/commentRss/151383.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/isware/services/trackbacks/151383.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 简单介绍libevent的使用方法&nbsp;&nbsp;<a href='http://www.cppblog.com/isware/archive/2011/07/19/151383.html'>阅读全文</a><img src ="http://www.cppblog.com/isware/aggbug/151383.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/isware/" target="_blank">艾斯维亚</a> 2011-07-19 15:07 <a href="http://www.cppblog.com/isware/archive/2011/07/19/151383.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转]Windows下模拟linux pipe</title><link>http://www.cppblog.com/isware/archive/2011/06/30/149807.html</link><dc:creator>艾斯维亚</dc:creator><author>艾斯维亚</author><pubDate>Thu, 30 Jun 2011 03:19:00 GMT</pubDate><guid>http://www.cppblog.com/isware/archive/2011/06/30/149807.html</guid><wfw:comment>http://www.cppblog.com/isware/comments/149807.html</wfw:comment><comments>http://www.cppblog.com/isware/archive/2011/06/30/149807.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/isware/comments/commentRss/149807.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/isware/services/trackbacks/149807.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Windows下模拟linux pipe&nbsp;&nbsp;<a href='http://www.cppblog.com/isware/archive/2011/06/30/149807.html'>阅读全文</a><img src ="http://www.cppblog.com/isware/aggbug/149807.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/isware/" target="_blank">艾斯维亚</a> 2011-06-30 11:19 <a href="http://www.cppblog.com/isware/archive/2011/06/30/149807.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转]Windows管道技术</title><link>http://www.cppblog.com/isware/archive/2011/06/30/149798.html</link><dc:creator>艾斯维亚</dc:creator><author>艾斯维亚</author><pubDate>Thu, 30 Jun 2011 01:52:00 GMT</pubDate><guid>http://www.cppblog.com/isware/archive/2011/06/30/149798.html</guid><wfw:comment>http://www.cppblog.com/isware/comments/149798.html</wfw:comment><comments>http://www.cppblog.com/isware/archive/2011/06/30/149798.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cppblog.com/isware/comments/commentRss/149798.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/isware/services/trackbacks/149798.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Windows管道技术简述&nbsp;&nbsp;<a href='http://www.cppblog.com/isware/archive/2011/06/30/149798.html'>阅读全文</a><img src ="http://www.cppblog.com/isware/aggbug/149798.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/isware/" target="_blank">艾斯维亚</a> 2011-06-30 09:52 <a href="http://www.cppblog.com/isware/archive/2011/06/30/149798.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>A Description of the C++ typename keyword</title><link>http://www.cppblog.com/isware/archive/2011/06/28/149665.html</link><dc:creator>艾斯维亚</dc:creator><author>艾斯维亚</author><pubDate>Tue, 28 Jun 2011 09:17:00 GMT</pubDate><guid>http://www.cppblog.com/isware/archive/2011/06/28/149665.html</guid><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: The purpose of this document is to describe the reasoning behind the inclusion of the typename keyword in standard C++, and explain where, when, and how it can and can't be used.&nbsp;&nbsp;<a href='http://www.cppblog.com/isware/archive/2011/06/28/149665.html'>阅读全文</a><img src ="http://www.cppblog.com/isware/aggbug/149665.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/isware/" target="_blank">艾斯维亚</a> 2011-06-28 17:17 <a href="http://www.cppblog.com/isware/archive/2011/06/28/149665.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>pipe、epoll总结及实例</title><link>http://www.cppblog.com/isware/archive/2011/06/11/148498.html</link><dc:creator>艾斯维亚</dc:creator><author>艾斯维亚</author><pubDate>Sat, 11 Jun 2011 09:24:00 GMT</pubDate><guid>http://www.cppblog.com/isware/archive/2011/06/11/148498.html</guid><wfw:comment>http://www.cppblog.com/isware/comments/148498.html</wfw:comment><comments>http://www.cppblog.com/isware/archive/2011/06/11/148498.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/isware/comments/commentRss/148498.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/isware/services/trackbacks/148498.html</trackback:ping><description><![CDATA[<div>1、pipe的关闭消息会被对端的epoll_wait捕获，但数据长度是0，可据此判断为pipe关闭消息。<br />2、epoll_wait返回的events中，当用户在epoll_ctl时设置了data.ptr，则不返回data.fd，用户只能使用data.ptr，因此自定义的结构中处理用户数据信息外，需要包含对应连接的socket描述符fd，否则无法收发数据。<br /><br />代码：<br />#include &lt;sys/types.h&gt;<br />#include &lt;unistd.h&gt;<br />#include &lt;stdio.h&gt;<br />#include &lt;stdlib.h&gt;<br /><br />#include &lt;sys/epoll.h&gt;<br /><br />#include &lt;sys/socket.h&gt;<br />#include &lt;arpa/inet.h&gt; // htons<br />#include &lt;string.h&gt; // bzero<br />//#include &lt;fcntl.h&gt;<br /><br />int main(int argc, char* argv[])<br />{<br />&nbsp;&nbsp; &nbsp;pid_t child;<br />&nbsp;&nbsp; &nbsp;int pipefd[2];<br />&nbsp;&nbsp; &nbsp;int e_fd = epoll_create(10);<br />&nbsp;&nbsp; &nbsp;if (-1 == e_fd)<br />&nbsp;&nbsp; &nbsp;{<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;perror("epoll_create");<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;exit(1);<br />&nbsp;&nbsp; &nbsp;}&nbsp;&nbsp; &nbsp;<br /><br />&nbsp;&nbsp; &nbsp;pipe(pipefd);<br />&nbsp;&nbsp; &nbsp;printf("fd0: %d, fd1: %d \n",pipefd[0], pipefd[1]);<br /><br />&nbsp;&nbsp; &nbsp;if ((child = fork()) == -1)<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; perror("fork");<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;close(e_fd);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit(1);<br />&nbsp;&nbsp;&nbsp; }<br /><br />&nbsp;&nbsp; &nbsp;if (child == 0)<br />&nbsp;&nbsp; &nbsp;{<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;close(pipefd[0]);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;sleep(1);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;write(pipefd[1],"a", 1);&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;sleep(2);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;write(pipefd[1],"b",1);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;sleep(3);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;close(pipefd[1]);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // socket<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;int fd, status;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;struct sockaddr_in remote;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;remote.sin_family = AF_INET;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;remote.sin_port = htons(5930);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;remote.sin_addr.s_addr = inet_addr("192.168.1.213");<br /><br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;fd = socket(AF_INET, SOCK_STREAM, 0);<br /><br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;sleep(3);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;status = connect(fd, (struct sockaddr*)&amp;remote, sizeof(struct sockaddr));<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if (status == -1)<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;perror("connect");<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;close(fd);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;exit(1);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br /><br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;sleep(2);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if (send(fd, "hello", 5, 0) == -1)<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;perror("send");<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;close(fd);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp; &nbsp;}<br />&nbsp;&nbsp; &nbsp;else <br />&nbsp;&nbsp; &nbsp;{<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;struct epoll_event evs[10];<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;struct epoll_event ev;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;struct P_ATR{<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;int fd;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} pipe_atr;<br /><br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;int nds = 0, i;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;close(pipefd[1]);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;pipe_atr.fd = pipefd[0];<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;ev.data.fd = pipefd[0];<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//ev.data.ptr = &amp;pipe_atr; // 不传入data.ptr<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;ev.events = EPOLLIN;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;epoll_ctl(e_fd, EPOLL_CTL_ADD, pipefd[0], &amp;ev);<br /><br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//sleep(5);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;nds = epoll_wait(e_fd, evs, 10, -1);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;printf("epoll_wait ret %d\n", nds);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;for (i = 0; i &lt; nds; i++)<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;int fd;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;printf("evs[%d].data.fd: %d, ", i, fd = evs[i].data.fd); // 我们在上面没有传入data.ptr，此时系统会返回data.fd<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;// printf("event fd: %d\n", fd = ((struct P_ATR*)(evs[i].data.ptr))-&gt;fd);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if ( fd == pipefd[0])<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;char readbuf[80];<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;int readbytes = read(pipefd[0], readbuf, 1);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;readbuf[readbytes] = 0;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;printf ("pipe event catch, recvdata = %s, size = %d\n", readbuf, readbytes);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;ev.events = EPOLLIN;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;epoll_ctl(e_fd, EPOLL_CTL_MOD, pipefd[0], &amp;ev);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;nds = epoll_wait(e_fd, evs, 10, -1);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("epoll_wait ret %d\n", nds);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (i = 0; i &lt; nds; i++)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int fd;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("evs[%d].data.fd: %d, ", i, fd = evs[i].data.fd);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // printf("event fd: %d\n", fd = ((struct P_ATR*)(evs[i].data.ptr))-&gt;fd);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( fd == pipefd[0])<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char readbuf[80];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int readbytes = read(pipefd[0], readbuf, 1);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; readbuf[readbytes] = 0;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf ("pipe event catch, recvdata = %s, size = %d\n", readbuf, readbytes);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;epoll_ctl(e_fd, EPOLL_CTL_MOD, pipefd[0], &amp;ev);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;nds = epoll_wait(e_fd, evs, 10, -1);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("epoll_wait ret %d\n", nds);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (i = 0; i &lt; nds; i++)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int fd;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("evs[%d].data.fd: %d, ", i, fd = evs[i].data.fd);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // printf("event fd: %d\n", fd = ((struct P_ATR*)(evs[i].data.ptr))-&gt;fd);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( fd == pipefd[0])<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char readbuf[80];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int readbytes = read(pipefd[0], readbuf, 1);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; readbuf[readbytes] = 0;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf ("pipe event catch, recvdata = %s, size = %d\n", readbuf, readbytes);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;close(pipefd[0]);<br /><br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;// socket<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;struct sockaddr_in addr;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;struct sockaddr_in remote;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;int newfd;<br /><br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;int sockfd = socket(AF_INET, SOCK_STREAM, 0);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if (-1 == sockfd)<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;perror("socket");<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;exit(0);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br /><br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;printf("new socket fd: %d\n", sockfd);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;addr.sin_family = AF_INET;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;addr.sin_port = htons(5930);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;addr.sin_addr.s_addr = INADDR_ANY;<br /><br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;bzero(&amp;addr.sin_zero, 8);<br /><br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if (bind(sockfd, (struct sockaddr*)&amp;addr, sizeof(struct sockaddr)) == -1)&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;perror("bind");<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;close(sockfd);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;exit(1);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;pipe_atr.fd = sockfd;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;ev.data.fd = sockfd;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;ev.data.ptr = &amp;pipe_atr; // 传入data.ptr<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ev.events = EPOLLIN;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; epoll_ctl(e_fd, EPOLL_CTL_ADD, sockfd, &amp;ev);<br /><br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if (listen(sockfd, 5) == -1) <br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;perror("listen");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;exit(1);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br /><br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;nds = epoll_wait(e_fd, evs, 10, -1);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("epoll_wait ret %d\n", nds);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;for (i = 0; i &lt; nds; i++)<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int fd;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;socklen_t len;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;int inds;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; printf("evs[%d].data.fd: %d, ", i, evs[i].data.fd); // 系统不会回填data.fd，其值是随机数字<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;printf("event fd: %d\n", fd = ((struct P_ATR*)(evs[i].data.ptr))-&gt;fd); // 系统返回用户传入的data.ptr<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( fd == sockfd)<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;len = sizeof (struct sockaddr);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;newfd = accept(sockfd, (struct sockaddr*)&amp;remote, &amp;len);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if (-1 == newfd)<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;perror("accept");<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;close(sockfd);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;exit(1);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;printf("new link create success, fd: %d\n", newfd);<br /><br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;struct P_ATR new_atr;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;new_atr.fd = newfd;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;ev.data.fd = newfd;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;ev.data.ptr = &amp;new_atr;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;ev.events = EPOLLIN;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;epoll_ctl(e_fd, EPOLL_CTL_ADD, newfd, &amp;ev);<br /><br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;inds = epoll_wait(e_fd, evs, 10, -1);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("epoll_wait ret %d\n", inds);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;for (i = 0; i &lt; inds; i++)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int fd;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;printf("evs[%d].data.fd: %d, ", i, evs[i].data.fd);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("event fd: %d\n", fd = ((struct P_ATR*)(evs[i].data.ptr))-&gt;fd);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if ( fd == newfd)<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; char readbuf[80];<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int readbytes = read(fd, readbuf, sizeof(readbuf));<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; readbuf[readbytes] = 0;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf ("pipe event catch, dataptr = %p, recvdata = %s, size = %d\n", evs[i].data.ptr, readbuf, readbytes);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;close(newfd);<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;close(sockfd);&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp; &nbsp;}<br /><br />&nbsp;&nbsp; &nbsp;close(e_fd);<br />&nbsp;&nbsp; &nbsp;return 0;<br /><br />}</div><img src ="http://www.cppblog.com/isware/aggbug/148498.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/isware/" target="_blank">艾斯维亚</a> 2011-06-11 17:24 <a href="http://www.cppblog.com/isware/archive/2011/06/11/148498.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转]如果我有时间，我会写更短的代码（王健硕）</title><link>http://www.cppblog.com/isware/archive/2011/06/07/148233.html</link><dc:creator>艾斯维亚</dc:creator><author>艾斯维亚</author><pubDate>Tue, 07 Jun 2011 14:04:00 GMT</pubDate><guid>http://www.cppblog.com/isware/archive/2011/06/07/148233.html</guid><wfw:comment>http://www.cppblog.com/isware/comments/148233.html</wfw:comment><comments>http://www.cppblog.com/isware/archive/2011/06/07/148233.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/isware/comments/commentRss/148233.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/isware/services/trackbacks/148233.html</trackback:ping><description><![CDATA[<div><p>eBay的代码量已经比Windows+Linux更多了。从我看来，这绝不是一种恭维，而是彻彻底底的技术人员的失败。从代码的角度，越短的代码，就越有力量。</p>  <p>Mark Twin曾经在给一个朋友的信中说道：<br /> </p><blockquote>我亲爱的朋友，如果我有更多的时间， 我就能给你写更短的信了。</blockquote>文字是这样，代码更是这样。  <p>有了面向对象的方式和一些简单的设计模式加一些重构，代码可以变得非常的简单，明了，易读，却依然保持灵活和强大。在百姓网，我们曾经把2000行 代码重构为250行（迷你朝歌），然后又把另外几千行代码重构为250行（迷你荆州）。我觉得250行代码是一个神奇的数量，很多的功能模块，就算用 PHP这样并不是完全面向对象的语言，也应该控制在250行之内。我个人的编程习惯和目标是，把每个函数控制在7行代码之内，把函数的数量控制到最小，用 最短的代码完成功能。我个人用的简化代码最有效的方式，就是写一段代码，彻底删掉，重写，然后再删掉。在如此十几遍之后所得到的代码，通常比第一次要好得 多。</p></div><div>代码量的增加，对于我们来说不是件好事。我们用拉锯战的方式在功能增加的同时，把代码量牢牢地卡在原地，并且不断减少。我们希望有一天，网站运营的PHP代码会被压缩到5000行之内。</div><div>就像对于代码的数量的追求一样，我们追求代码的质量，我们追求最实用的解决方案（我们是彻彻底底的实用主义者，希望用最小的代价解决问题），我们也追求网站的速度，内容的质量。。。技术人员，就应该有些技术人员的样子。毕竟，无论做什么，都要有些追求的。。。</div><img src ="http://www.cppblog.com/isware/aggbug/148233.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/isware/" target="_blank">艾斯维亚</a> 2011-06-07 22:04 <a href="http://www.cppblog.com/isware/archive/2011/06/07/148233.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>