﻿<?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>IT博客-记录成长的过程</title><link>http://www.cnitblog.com/chenlei/</link><description /><language>zh-cn</language><lastBuildDate>Wed, 29 Apr 2026 05:59:02 GMT</lastBuildDate><pubDate>Wed, 29 Apr 2026 05:59:02 GMT</pubDate><ttl>60</ttl><item><title>前台进程、后台进程、守护进程</title><link>http://www.cnitblog.com/chenlei/archive/2011/10/16/76078.html</link><dc:creator>Mr.雷</dc:creator><author>Mr.雷</author><pubDate>Sun, 16 Oct 2011 13:39:00 GMT</pubDate><guid>http://www.cnitblog.com/chenlei/archive/2011/10/16/76078.html</guid><wfw:comment>http://www.cnitblog.com/chenlei/comments/76078.html</wfw:comment><comments>http://www.cnitblog.com/chenlei/archive/2011/10/16/76078.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/chenlei/comments/commentRss/76078.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/chenlei/services/trackbacks/76078.html</trackback:ping><description><![CDATA[前台进程就是用户使用的有控制终端的进程，守护进程是从来不需要用户输入的程序，它是一种特许的后台进程。<br /><div><span style="border-collapse: collapse; font-family: song, Verdana; font-size: 14px; line-height: 22px; ">基本上任何一个程序都可以后台运行，但守护进程是具有特殊要求的程序，比如要脱离自己的父进程，成为自己的会话组长等，这些要在代码中显式地写出来</span><span style="border-collapse: collapse; font-family: song, Verdana; font-size: 14px; line-height: 22px; "><br style="word-wrap: break-word; line-height: normal; " /></span><span style="border-collapse: collapse; font-family: song, Verdana; font-size: 14px; line-height: 22px; "><br style="word-wrap: break-word; line-height: normal; " /></span><span style="border-collapse: collapse; font-family: song, Verdana; font-size: 14px; line-height: 22px; ">换句话说，守护进程肯定是后台进程，但反之不成立。守护进程顾名思义，主要用于一些长期运行，守护着自己的职责（监听端口，监听服务等）。我们的系统下就有很多守护进程。<br /><div>很多系统服务名字后面带个d，就是daemon、守护的意思。另外unistd.h中定义了daemon()这个函数可以把当前进程状态转化为daemon进程。<br /><div>在<span href="tag.php?name=linux" style="word-wrap: break-word; line-height: normal; cursor: pointer; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #ff0000; white-space: nowrap; ">linux</span>下使用 &amp; 可以使程序进入后台运行模式</div></div></span></div><img src ="http://www.cnitblog.com/chenlei/aggbug/76078.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/chenlei/" target="_blank">Mr.雷</a> 2011-10-16 21:39 <a href="http://www.cnitblog.com/chenlei/archive/2011/10/16/76078.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>十进制转二进制、八进制、十六进制的经典程序</title><link>http://www.cnitblog.com/chenlei/archive/2011/09/03/75338.html</link><dc:creator>Mr.雷</dc:creator><author>Mr.雷</author><pubDate>Sat, 03 Sep 2011 13:54:00 GMT</pubDate><guid>http://www.cnitblog.com/chenlei/archive/2011/09/03/75338.html</guid><wfw:comment>http://www.cnitblog.com/chenlei/comments/75338.html</wfw:comment><comments>http://www.cnitblog.com/chenlei/archive/2011/09/03/75338.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/chenlei/comments/commentRss/75338.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/chenlei/services/trackbacks/75338.html</trackback:ping><description><![CDATA[<div><span style="font-family: 宋体; font-size: 12px; ">#include &lt;iostream.h&gt;</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">//十进制数转换成二进制数字</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">void fun_1(int n)</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">{</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp;if(n&lt;2)&nbsp;&nbsp;&nbsp;</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout&lt;&lt;n;</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp;if(n&gt;=2)&nbsp;&nbsp;</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp;{</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fun_1(n/2);</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout&lt;&lt;n%2;</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp;}</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">}</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">//十进制数字转换成八进制数字</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">void fun_2(int n)</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">{</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;if(n&lt;8)&nbsp;&nbsp;&nbsp;</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout&lt;&lt;n;</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;if(n&gt;=8)&nbsp;&nbsp;</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;{</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp; fun_2(n/8);</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp; cout&lt;&lt;n%8;</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;}</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">}</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">//十进制数转换成十六进制数字</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">void fun_3(int n)</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">{</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;switch(n)</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;{</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 10:&nbsp;&nbsp;&nbsp;cout&lt;&lt;"A"; break;</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 11:&nbsp;&nbsp;&nbsp;cout&lt;&lt;"B"; break;</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 12:&nbsp;&nbsp;&nbsp;cout&lt;&lt;"C"; break;</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 13:&nbsp;&nbsp;&nbsp;cout&lt;&lt;"D"; break;</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 14:&nbsp;&nbsp;&nbsp;cout&lt;&lt;"E"; break;</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 15:&nbsp;&nbsp;&nbsp;cout&lt;&lt;"F"; break;</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;default:&nbsp;&nbsp;&nbsp;cout&lt;&lt;n;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;}</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">void fun_4(int n)</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">{</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp;if(n&lt;16)&nbsp;&nbsp;&nbsp;</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fun_3(n);</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp;if(n&gt;=16)&nbsp;&nbsp;</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp;{</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fun_4(n/16);</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fun_3(n%16);</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp;}</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">}</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">//主函数</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">void main()</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">{</span>&nbsp;<span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp; int n;</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp; cout&lt;&lt;"请输入n的值:&nbsp;&nbsp;"&lt;&lt;endl;</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp; cin&gt;&gt;n;</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp; cout&lt;&lt;"十进制数字转换成二进制，八进制，十六进制数字结果如下："&lt;&lt;endl;</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp; fun_1(n);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp;&nbsp;cout&lt;&lt;endl;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//输出结果换行</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp; fun_2(n);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp;&nbsp;cout&lt;&lt;endl;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp; fun_4(n);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;<span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">&nbsp;&nbsp;&nbsp; cout&lt;&lt;endl;&nbsp;&nbsp;&nbsp;</span>&nbsp;<span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">}</span>&nbsp;<span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; "><br /></span><span style="font-family: 宋体; font-size: 12px; ">输出结果：</span></div><img src ="http://www.cnitblog.com/chenlei/aggbug/75338.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/chenlei/" target="_blank">Mr.雷</a> 2011-09-03 21:54 <a href="http://www.cnitblog.com/chenlei/archive/2011/09/03/75338.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>strcpy()、memcpy()、memmove()、memset()的实现</title><link>http://www.cnitblog.com/chenlei/archive/2011/08/24/75173.html</link><dc:creator>Mr.雷</dc:creator><author>Mr.雷</author><pubDate>Wed, 24 Aug 2011 14:50:00 GMT</pubDate><guid>http://www.cnitblog.com/chenlei/archive/2011/08/24/75173.html</guid><wfw:comment>http://www.cnitblog.com/chenlei/comments/75173.html</wfw:comment><comments>http://www.cnitblog.com/chenlei/archive/2011/08/24/75173.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/chenlei/comments/commentRss/75173.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/chenlei/services/trackbacks/75173.html</trackback:ping><description><![CDATA[<div><p style="line-height: 18px; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; font-family: Verdana, ����; font-size: 12px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">strcpy(), 字符串拷贝.<br />char *strcpy(char *strDest, const char *strSrc)<br />{<br />&nbsp;&nbsp;&nbsp; assert((strDest!=NULL) &amp;&amp; (strSrc !=NULL));<br />&nbsp;&nbsp;&nbsp; char *address = strDest;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp; while( (*strDest++ = * strSrc++) != '\0')&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NULL ;&nbsp;<br />&nbsp;&nbsp;&nbsp; return address ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />}</p><p style="line-height: 18px; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; font-family: Verdana, ����; font-size: 12px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">memcpy, 拷贝不重叠的内存块&nbsp;<br />void *memcpy(void* pvTo, void* pvFrom, size_t size) //byte是java里的变量类型<br />{<br />assert(pvTo != NULL &amp;&amp; pvFrom != NULL);<br />void* pbTo = (byte*)pvTo;<br />void* pbFrom = (byte*)pvFrom;<br />/* 内存块重叠吗？如果重叠，就使用memmove */<br />assert(pbTo&gt;=pbFrom+size || pbFrom&gt;=pbTo+size);<br />while(size--&gt;0)<br />&nbsp;&nbsp;&nbsp; *pbTo++ == *pbFrom++;<br />return pvTo;<br />}</p><p style="line-height: 18px; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; font-family: Verdana, ����; font-size: 12px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">void *MemCopy(void *dest,const void *src,size_t count)<br />{<br />&nbsp;&nbsp;&nbsp; char *pDest=static_cast&lt;char *&gt;(dest);<br />&nbsp;&nbsp;&nbsp; const char *pSrc=static_cast&lt;const char *&gt;(src);<br />&nbsp;&nbsp;&nbsp; if( pDest&gt;pSrc &amp;&amp; pDest&lt;pSrc+count )<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(size_t i=count-1; i&lt;=0; ++i)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pDest[i]=pSrc[i];<br />&nbsp;&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;&nbsp; for(size_t i=0; i&lt;count; ++i)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pDest[i]=pSrc[i];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; return pDest;<br />}</p><p style="line-height: 18px; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; font-family: Verdana, ����; font-size: 12px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">void *Memmove(void *Dst, const void*Src,size_t count)<br />{<br />assert(Dst &amp;&amp; Src);<br />void* pDst = Dst;<br />if (Dst&lt;Src &amp;&amp; (char*)Dst &gt; (char*)Src + count)<br />{<br />while(count--)<br />{<br />&nbsp;&nbsp; *(char*)Dst = *(char*)Src;<br />&nbsp;&nbsp; Dst = (char*)Dst + 1;<br />&nbsp;&nbsp; Src = (char*)Src + 1;<br />}<br />}<br />else<br />{<br />&nbsp;&nbsp; Dst = (char*)Dst + count - 1;<br />&nbsp;&nbsp; Src = (char*)Src + count - 1;<br />&nbsp;&nbsp; while(count--)<br />&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *(char*)Dst = *(char*)Src;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dst = (char*)Dst -1 ;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Src = (char*)Src -1 ;<br />&nbsp;&nbsp; }<br />}<br />return pDst;<br />}</p><p style="line-height: 18px; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; font-family: Verdana, ����; font-size: 12px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><br />void* memmove(void *dest, const void *src,size_t n)&nbsp;<br />{&nbsp;<br />&nbsp;&nbsp;&nbsp; if (n == 0) return 0;&nbsp;<br />&nbsp;&nbsp;&nbsp; if (dest == NULL) return 0;&nbsp;<br />&nbsp;&nbsp;&nbsp; if (src == NULL)&nbsp;&nbsp;&nbsp; return 0;&nbsp;<br />&nbsp;&nbsp;&nbsp; char *psrc = (char*)src;&nbsp;<br />&nbsp;&nbsp;&nbsp; char *pdest = (char*)dest;&nbsp;<br />&nbsp;&nbsp;&nbsp; if((dest &lt;= psrc) || (pdest &gt;= psrc + n)) /*检查是否有重叠问题 */&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(int i=0; i &lt; n; i++) /*正向拷贝*/&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *pdest = *psrc;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; psrc++;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pdest++;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else /*反向拷贝*/&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; psrc += n;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pdest += n;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(int i=0;i&lt;n;i++)&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; psrc--;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pdest--;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *pdest = *psrc;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp;<br />&nbsp;&nbsp; return dest;<br />}</p><p style="line-height: 18px; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; font-family: Verdana, ����; font-size: 12px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">memset:把buffer所指内存区域的前count个字节设置成字符c</p><p style="line-height: 18px; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; font-family: Verdana, ����; font-size: 12px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">void * Memset(void* buffer, int c, int count)<br />{<br />char* pvTo=(char*)buffer;<br />assert(buffer != NULL);<br />while(count--&gt;0)<br />*pvTo++=(char)c;<br />return buffer;<br />}</p></div><img src ="http://www.cnitblog.com/chenlei/aggbug/75173.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/chenlei/" target="_blank">Mr.雷</a> 2011-08-24 22:50 <a href="http://www.cnitblog.com/chenlei/archive/2011/08/24/75173.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>空指针与迷途指针（野指针）的区别</title><link>http://www.cnitblog.com/chenlei/archive/2011/08/20/75130.html</link><dc:creator>Mr.雷</dc:creator><author>Mr.雷</author><pubDate>Sat, 20 Aug 2011 03:12:00 GMT</pubDate><guid>http://www.cnitblog.com/chenlei/archive/2011/08/20/75130.html</guid><wfw:comment>http://www.cnitblog.com/chenlei/comments/75130.html</wfw:comment><comments>http://www.cnitblog.com/chenlei/archive/2011/08/20/75130.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/chenlei/comments/commentRss/75130.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/chenlei/services/trackbacks/75130.html</trackback:ping><description><![CDATA[<div><p style="line-height: normal; color: #333333; font-family: Arial; font-size: 14px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">当free或delete一个指针的时候，实际上仅仅是让编译器释放内存，但指针本身依然存在。这时它就像是一个迷途指针，处于悬浮状态。当使用语句P=0（NULL）之后，可以把迷途指针改为空指针。不可以直接使用一个迷途指针或者空指针，这样会使得程序造成崩溃。但是同样是崩溃，空指针造成的崩溃相比于迷途指针造成的崩溃是一种可预料的崩溃。调试起来也比较方便。</p><p style="line-height: normal; color: #333333; font-family: Arial; font-size: 14px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">此外，malloc/free与new/delete的最大区别是前者是库函数而后者是运算符。</p></div><img src ="http://www.cnitblog.com/chenlei/aggbug/75130.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/chenlei/" target="_blank">Mr.雷</a> 2011-08-20 11:12 <a href="http://www.cnitblog.com/chenlei/archive/2011/08/20/75130.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>pthread_join与pthread_detach</title><link>http://www.cnitblog.com/chenlei/archive/2010/11/08/71074.html</link><dc:creator>Mr.雷</dc:creator><author>Mr.雷</author><pubDate>Mon, 08 Nov 2010 08:05:00 GMT</pubDate><guid>http://www.cnitblog.com/chenlei/archive/2010/11/08/71074.html</guid><wfw:comment>http://www.cnitblog.com/chenlei/comments/71074.html</wfw:comment><comments>http://www.cnitblog.com/chenlei/archive/2010/11/08/71074.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/chenlei/comments/commentRss/71074.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/chenlei/services/trackbacks/71074.html</trackback:ping><description><![CDATA[<p id="zw-1266edb376azrNzxW2dbd2a" zid="3" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.75em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 'trebuchet ms'; font-size: 13px; ">pthread_t&nbsp;&nbsp;&nbsp; pthr;<br id="zw-1266eef367bu0g2Zh2dbd2a" zid="7" /></p><p id="zw-1266eef367bdtB_se2dbd2a" zid="8" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.75em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 'trebuchet ms'; font-size: 13px; ">pthread_create(&amp;pthr, NULL, thread_handler, NULL);</p><p id="zw-1266ef259473gv43_2dbd2a" zid="9" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.75em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 'trebuchet ms'; font-size: 13px; ">...</p><p id="zw-1266ef260d9gfGXkC2dbd2a" zid="10" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.75em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 'trebuchet ms'; font-size: 13px; ">void* thread_handler(void* arg)</p><p id="zw-1266ef28e1bAdYA52dbd2a" zid="11" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.75em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 'trebuchet ms'; font-size: 13px; ">{</p><p id="zw-1266ef2c1cdlH5BK22dbd2a" zid="15" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.75em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 'trebuchet ms'; font-size: 13px; ">&nbsp;&nbsp;&nbsp; /* do something */</p><p id="zw-1266ef29474dOuX4K2dbd2a" zid="14" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.75em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 'trebuchet ms'; font-size: 13px; "><span zid="60" id="zw-1266f12c8e3tifchT2dbd2a" style="color: #ff0000; ">&nbsp;&nbsp;&nbsp; pthread_join(pthr, NULL);</span><span zid="41" id="zw-1266f0fed84VX7dmi2dbd2a"></span></p><p id="zw-1266f0ff703YZnGh42dbd2a" zid="42" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.75em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 'trebuchet ms'; font-size: 13px; ">}</p><p id="zw-1266f1035acf-2MCb2dbd2a" zid="43" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.75em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 'trebuchet ms'; font-size: 13px; "><br id="zw-1266f1035acuGHnUK2dbd2a" zid="4" /></p><p id="zw-1266f128524UcH3n2dbd2a" zid="5" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.75em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 'trebuchet ms'; font-size: 13px; ">上面的代码不好使，pthread_join不能放在pthread调用的handler内，虽然不报错，但是<span zid="59" id="zw-1266f1285246qLswR2dbd2a">thread无法正常回收，如果多次创建thread，内存会越来越大（另一种形式的内存泄露）。</span></p><p id="zw-1266f1230cbAfJbVP2dbd2a" zid="61" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.75em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 'trebuchet ms'; font-size: 13px; "><span zid="62" id="zw-1266f1230cbqDR-cA2dbd2a">正确的做法是在</span>handler外面pthread_join:</p><p id="zw-1266f10b7ebtm1_k2dbd2a" zid="44" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.75em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 'trebuchet ms'; font-size: 13px; "><br zid="45" id="zw-1266f10b7ebjXTBXp2dbd2a" /></p><p id="zw-1266f10a9cbmR-K_F2dbd2a" zid="46" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.75em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 'trebuchet ms'; font-size: 13px; ">pthread_t&nbsp;&nbsp;&nbsp; pthr;<br id="zw-1266f10a9cbTlXlnG2dbd2a" zid="47" /></p><p id="zw-1266f10a9cc3xbAS2dbd2a" zid="48" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.75em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 'trebuchet ms'; font-size: 13px; ">pthread_create(&amp;pthr, NULL, thread_handler, NULL);</p><p zid="49" id="zw-1266f10d1ffpp1DXx2dbd2a" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.75em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 'trebuchet ms'; font-size: 13px; "><span zid="63" id="zw-1266f12ed29Vx3x512dbd2a" style="color: #ff0000; ">pthread_join(pthr, NULL);</span><span id="zw-1266f10d1feib2gy2dbd2a" zid="50"></span></p><p id="zw-1266f10a9cckS1dd-2dbd2a" zid="51" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.75em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 'trebuchet ms'; font-size: 13px; ">...</p><p id="zw-1266f10a9cc1ftAdN2dbd2a" zid="52" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.75em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 'trebuchet ms'; font-size: 13px; ">void* thread_handler(void* arg)</p><p id="zw-1266f10a9ccbsqtCc2dbd2a" zid="53" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.75em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 'trebuchet ms'; font-size: 13px; ">{</p><p id="zw-1266f10a9cdxVT5Rv2dbd2a" zid="54" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.75em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 'trebuchet ms'; font-size: 13px; ">&nbsp;&nbsp;&nbsp; /* do something */</p><p id="zw-1266f10a9cd061pxh2dbd2a" zid="55" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.75em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 'trebuchet ms'; font-size: 13px; ">}</p><p id="zw-1266f10a9cdIIOlOJ2dbd2a" zid="56" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.75em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 'trebuchet ms'; font-size: 13px; "><br zid="57" id="zw-1266f10a9cdG4aHoE2dbd2a" /></p><p id="zw-1266ef73a26Z6jrt12dbd2a" zid="31" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.75em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 'trebuchet ms'; font-size: 13px; ">如果不用pthread_join，改用pthread_detach呢？那最方便，但要注意：pthread_detach最好是放在handler里面第一句。</p><p id="zw-1266f1345d7cZ4pdn2dbd2a" zid="64" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.75em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 'trebuchet ms'; font-size: 13px; "><br zid="65" id="zw-1266f1345d8OJ3agz2dbd2a" /></p><p id="zw-1266ef7413dFUZr9f2dbd2a" zid="21" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.75em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 'trebuchet ms'; font-size: 13px; ">void* thread_handler(void* arg)</p><p id="zw-1266ef7413e2X5GJD2dbd2a" zid="22" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.75em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 'trebuchet ms'; font-size: 13px; ">{</p><p id="zw-1266ef7413eNYUx8N2dbd2a" zid="23" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.75em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 'trebuchet ms'; font-size: 13px; ">&nbsp;&nbsp;&nbsp; pthread_detach(pthr);<br id="zw-1266ef7413eGp6U4_2dbd2a" zid="24" /></p><p id="zw-1266ef7413fgG6R8-2dbd2a" zid="25" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.75em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 'trebuchet ms'; font-size: 13px; ">&nbsp;&nbsp;&nbsp; /* do something */</p><p id="zw-1266ef7413fLcrWj2dbd2a" zid="28" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.75em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 'trebuchet ms'; font-size: 13px; ">}</p><p id="zw-1266f134bc3cAeU7W2dbd2a" zid="66" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.75em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 'trebuchet ms'; font-size: 13px; "><br zid="67" id="zw-1266f134bc3gVnhTN2dbd2a" /></p><p id="zw-1266ef69ea9OPJue92dbd2a" zid="30" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.75em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; font-family: 'trebuchet ms'; font-size: 13px; ">如果pthread_create后紧跟pthread_detach，有可能会出错。</p><img src ="http://www.cnitblog.com/chenlei/aggbug/71074.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/chenlei/" target="_blank">Mr.雷</a> 2010-11-08 16:05 <a href="http://www.cnitblog.com/chenlei/archive/2010/11/08/71074.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>pageContext，request，session，application生命周期</title><link>http://www.cnitblog.com/chenlei/archive/2010/10/28/70654.html</link><dc:creator>Mr.雷</dc:creator><author>Mr.雷</author><pubDate>Thu, 28 Oct 2010 07:24:00 GMT</pubDate><guid>http://www.cnitblog.com/chenlei/archive/2010/10/28/70654.html</guid><wfw:comment>http://www.cnitblog.com/chenlei/comments/70654.html</wfw:comment><comments>http://www.cnitblog.com/chenlei/archive/2010/10/28/70654.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/chenlei/comments/commentRss/70654.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/chenlei/services/trackbacks/70654.html</trackback:ping><description><![CDATA[<span style="COLOR:red"></span><p>&nbsp;</p><span style="FONT-FAMILY: Comic Sans MS "></span>
<p style="line-height: normal; color: rgb(102, 102, 102); font-family: Arial; font-size: 14px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">request是封装client端（也就是用户通过browser）提交的请求数据和属性的对象。&nbsp;<br style="line-height: normal; ">response是封装web server端响应数据和属性的对象。</p><p style="line-height: normal; color: rgb(102, 102, 102); font-family: Arial; font-size: 14px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><br style="line-height: normal; ">我们经常会将pageContext、request、session和application混为一谈，因为它们都可以通过setAttribute()和getAttribute()来设定或读取属性。但它们之间是有别的，它们最大的区别在于使用范围。&nbsp;<br style="line-height: normal; "><br style="line-height: normal; ">pageContext对象的范围只适用于当前页面范围，即超过这个页面就不能够使用了。所以使用pageContext对象向其它页面传递参数是不可能的。&nbsp;<br style="line-height: normal; "><br style="line-height: normal; ">request对象的范围是指在一JSP网页发出请求到另一个JSP网页之间，随后这个属性就失效。&nbsp;<br style="line-height: normal; "><br style="line-height: normal; ">session的作用范围为一段用户持续和服务器所连接的时间，但与服务器断线后，这个属性就无效。比如断网或者关闭浏览器。&nbsp;<br style="line-height: normal; "><br style="line-height: normal; ">application的范围在服务器一开始执行服务，到服务器关闭为止。它的范围最大，生存周期最长。</p><p style="line-height: normal; color: rgb(102, 102, 102); font-family: Arial; font-size: 14px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">session主要功能：验证用户是否登录。在几个页面上都能取得。<br style="line-height: normal; ">request：只有&lt;jsp:forward page=" "&gt;跳转页面才能取得。<br style="line-height: normal; ">application:只要设置一次，所有的网页窗口都可以取得数据。<br style="line-height: normal; ">application session request-&gt;都需要跨多个页面<br style="line-height: normal; ">设置过多application 或每一个session保存过多的对象则性能降低<br style="line-height: normal; ">能使用request 就不要使用session 能使用session的就不要使用application</p><p style="line-height: normal; color: rgb(102, 102, 102); font-family: Arial; font-size: 14px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">application应用：在线人员统计、在线人员名单列表<br style="line-height: normal; ">pageContext:默认情况下一个页面的保存范围<br style="line-height: normal; ">实际上四种属性范围都是通过pageContext属性完成的<br style="line-height: normal; ">pageContext.setAttribute("name","mldn",PageContext.<font color="#ff0000" style="line-height: normal; ">REQUEST</font>_SCOPE);更改红字的名字得到。<br style="line-height: normal; ">在另外一页用request去接收String name=(String)request.getAttribute("name");&lt;%=name%&gt;;<br style="line-height: normal; ">如果要释放application资源要重新启动服务器<br style="line-height: normal; ">四种属性范围都是依靠pageContext展开的，但是在开发中，往往使用session和request范围最多。</p><img src ="http://www.cnitblog.com/chenlei/aggbug/70654.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/chenlei/" target="_blank">Mr.雷</a> 2010-10-28 15:24 <a href="http://www.cnitblog.com/chenlei/archive/2010/10/28/70654.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一个Servlet生命周期</title><link>http://www.cnitblog.com/chenlei/archive/2010/10/28/70653.html</link><dc:creator>Mr.雷</dc:creator><author>Mr.雷</author><pubDate>Thu, 28 Oct 2010 07:17:00 GMT</pubDate><guid>http://www.cnitblog.com/chenlei/archive/2010/10/28/70653.html</guid><wfw:comment>http://www.cnitblog.com/chenlei/comments/70653.html</wfw:comment><comments>http://www.cnitblog.com/chenlei/archive/2010/10/28/70653.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/chenlei/comments/commentRss/70653.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/chenlei/services/trackbacks/70653.html</trackback:ping><description><![CDATA[<span  style="font-family: 宋体; font-size: 14px; line-height: 22px; ">从Tomcat处理用户请求，我们可以清晰的看到容器Servlet的生命周期管理过程：</span><span  style="font-family: 宋体; font-size: 14px; line-height: 22px; "><br></span><span  style="font-family: 宋体; font-size: 14px; line-height: 22px; ">　　1、客户发出请求—&gt;Web 服务器转发到Web容器Tomcat；</span><span  style="font-family: 宋体; font-size: 14px; line-height: 22px; "><br></span><span  style="font-family: 宋体; font-size: 14px; line-height: 22px; ">　　2、Tomcat主线程对转发来用户的请求做出响应创建两个对象：HttpServletRequest和HttpServletResponse；</span><span  style="font-family: 宋体; font-size: 14px; line-height: 22px; "><br></span><span  style="font-family: 宋体; font-size: 14px; line-height: 22px; ">　　3、从请求中的URL中找到正确Servlet，Tomcat为其创建或者分配一个线程，同时把2创建的两个对象传递给该线程；</span><span  style="font-family: 宋体; font-size: 14px; line-height: 22px; "><br></span><span  style="font-family: 宋体; font-size: 14px; line-height: 22px; ">　　4、Tomcat调用Servlet的servic()方法，根据请求参数的不同调用doGet()或者doPost()方法；</span><span  style="font-family: 宋体; font-size: 14px; line-height: 22px; "><br></span><span  style="font-family: 宋体; font-size: 14px; line-height: 22px; ">　　5、假设是HTTP GET请求，doGet()方法生成静态页面，并组合到响应对象里；</span><span  style="font-family: 宋体; font-size: 14px; line-height: 22px; "><br></span><span  style="font-family: 宋体; font-size: 14px; line-height: 22px; ">　　6、Servlet线程结束，Tomcat将响应对象转换为HTTP响应发回给客户，同时删除请求和响应对象。</span><span  style="font-family: 宋体; font-size: 14px; line-height: 22px; "><br></span><span  style="font-family: 宋体; font-size: 14px; line-height: 22px; ">　　从该过程中，我们可以理解Servlet的生命周期：Servlet类加载（对应第3步）；Servlet实例化（对应第3步）；调用init方法（对应第3步）；调用service()方法（对应4、5步）；调用destroy()方法（对应第6步）。</span>
<img src ="http://www.cnitblog.com/chenlei/aggbug/70653.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/chenlei/" target="_blank">Mr.雷</a> 2010-10-28 15:17 <a href="http://www.cnitblog.com/chenlei/archive/2010/10/28/70653.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java中private, public,protected的区别</title><link>http://www.cnitblog.com/chenlei/archive/2010/10/28/70649.html</link><dc:creator>Mr.雷</dc:creator><author>Mr.雷</author><pubDate>Thu, 28 Oct 2010 06:21:00 GMT</pubDate><guid>http://www.cnitblog.com/chenlei/archive/2010/10/28/70649.html</guid><wfw:comment>http://www.cnitblog.com/chenlei/comments/70649.html</wfw:comment><comments>http://www.cnitblog.com/chenlei/archive/2010/10/28/70649.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/chenlei/comments/commentRss/70649.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/chenlei/services/trackbacks/70649.html</trackback:ping><description><![CDATA[<h4 class="TextColor1" id="subjcns!1b34027d7bc078d!122" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; ">java中private, public,protected的区别</h4><div class="bvMsg" id="msgcns!1b34027d7bc078d!122" style="font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; "><div><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; "><span style="line-height: 18px; font-size: 9pt; "><font face="宋体">在说明这四个关键字之前，我想就</font></span><span lang="EN-US" style="line-height: 18px; font-size: 9pt; font-family: Tahoma; ">class</span><span style="line-height: 18px; font-size: 9pt; "><font face="宋体">之间的关系做一个简单的定义，对于继承自己的</font></span><span lang="EN-US" style="line-height: 18px; font-size: 9pt; font-family: Tahoma; ">class</span><span style="line-height: 18px; font-size: 9pt; "><font face="宋体">，</font></span><span lang="EN-US" style="line-height: 18px; font-size: 9pt; font-family: Tahoma; ">base class</span><span style="line-height: 18px; font-size: 9pt; "><font face="宋体">可以认为他们都是自己的子女，而对于和自己一个目录下的</font></span><span lang="EN-US" style="line-height: 18px; font-size: 9pt; font-family: Tahoma; ">classes</span><span style="line-height: 18px; font-size: 9pt; "><font face="宋体">，认为都是自己的朋友。</font></span><span lang="EN-US" style="line-height: 18px; font-size: 9pt; font-family: Tahoma; ">&nbsp;<br /></span><br />&nbsp;<span lang="EN-US" style="line-height: 18px; font-size: 9pt; font-family: Tahoma; ">1</span><span style="line-height: 18px; font-size: 9pt; "><font face="宋体">、</font></span><span lang="EN-US" style="line-height: 18px; font-size: 9pt; font-family: Tahoma; ">public</span><span style="line-height: 18px; font-size: 9pt; "><font face="宋体">：</font></span><span lang="EN-US" style="line-height: 18px; font-size: 9pt; font-family: Tahoma; ">public</span><span style="line-height: 18px; font-size: 9pt; "><font face="宋体">表明该数据成员、成员函数是对所有用户开放的，所有用户都可以直接进行调用<br /></font></span>&nbsp;<span lang="EN-US" style="line-height: 18px; font-size: 9pt; font-family: Tahoma; ">2</span><span style="line-height: 18px; font-size: 9pt; "><font face="宋体">、</font></span><span lang="EN-US" style="line-height: 18px; font-size: 9pt; font-family: Tahoma; ">private</span><span style="line-height: 18px; font-size: 9pt; "><font face="宋体">：</font></span><span lang="EN-US" style="line-height: 18px; font-size: 9pt; font-family: Tahoma; ">private</span><span style="line-height: 18px; font-size: 9pt; "><font face="宋体">表示私有，私有的意思就是除了</font></span><span lang="EN-US" style="line-height: 18px; font-size: 9pt; font-family: Tahoma; ">class</span><span style="line-height: 18px; font-size: 9pt; "><font face="宋体">自己之外，任何人都不可以直接使用，私有财产神圣不可侵犯嘛，即便是子女，朋友，都不可以使用。<br /></font></span>&nbsp;<span lang="EN-US" style="line-height: 18px; font-size: 9pt; font-family: Tahoma; ">3</span><span style="line-height: 18px; font-size: 9pt; "><font face="宋体">、</font></span><span lang="EN-US" style="line-height: 18px; font-size: 9pt; font-family: Tahoma; ">protected</span><span style="line-height: 18px; font-size: 9pt; "><font face="宋体">：</font></span><span lang="EN-US" style="line-height: 18px; font-size: 9pt; font-family: Tahoma; ">protected</span><span style="line-height: 18px; font-size: 9pt; "><font face="宋体">对于子女、朋友来说，就是</font></span><span lang="EN-US" style="line-height: 18px; font-size: 9pt; font-family: Tahoma; ">public</span><span style="line-height: 18px; font-size: 9pt; "><font face="宋体">的，可以自由使用，没有任何限制，而对于其他的外部</font></span><span lang="EN-US" style="line-height: 18px; font-size: 9pt; font-family: Tahoma; ">class</span><span style="line-height: 18px; font-size: 9pt; "><font face="宋体">，</font></span><span lang="EN-US" style="line-height: 18px; font-size: 9pt; font-family: Tahoma; ">protected</span><span style="line-height: 18px; font-size: 9pt; "><font face="宋体">就变成</font></span><span lang="EN-US" style="line-height: 18px; font-size: 9pt; font-family: Tahoma; ">private</span><span style="line-height: 18px; font-size: 9pt; "><font face="宋体">。</font></span><span lang="EN-US" style="line-height: 18px; font-size: 9pt; font-family: Tahoma; "></span></p><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; "><span lang="EN-US" style="line-height: 18px; font-size: 9pt; font-family: Tahoma; "></span><span lang="EN-US" style="line-height: 18px; font-size: 9pt; font-family: Tahoma; ">作用域&nbsp;当前类&nbsp;同一package&nbsp;子孙类&nbsp;其他package&nbsp;</span></p><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; "><span lang="EN-US" style="line-height: 18px; font-size: 9pt; font-family: Tahoma; ">public&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8730;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&#8730;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&#8730;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8730;&nbsp;<br /><br />protected&nbsp;&#8730;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8730;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8730;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#215;&nbsp;<br /><br />friendly&nbsp;&nbsp;&nbsp;&nbsp; &#8730;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8730;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#215;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#215;&nbsp;<br /><br />private&nbsp;&nbsp;&nbsp;&nbsp; &#8730;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#215;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#215;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#215;&nbsp;<br /><br />不写时默认为friendly&nbsp;</span></p></div></div><img src ="http://www.cnitblog.com/chenlei/aggbug/70649.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/chenlei/" target="_blank">Mr.雷</a> 2010-10-28 14:21 <a href="http://www.cnitblog.com/chenlei/archive/2010/10/28/70649.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>C++中volatile关键字的作用（volatile应理解为直接存取原始内存地址，英文意思为易改变的）</title><link>http://www.cnitblog.com/chenlei/archive/2010/10/17/70222.html</link><dc:creator>Mr.雷</dc:creator><author>Mr.雷</author><pubDate>Sun, 17 Oct 2010 13:55:00 GMT</pubDate><guid>http://www.cnitblog.com/chenlei/archive/2010/10/17/70222.html</guid><wfw:comment>http://www.cnitblog.com/chenlei/comments/70222.html</wfw:comment><comments>http://www.cnitblog.com/chenlei/archive/2010/10/17/70222.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/chenlei/comments/commentRss/70222.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/chenlei/services/trackbacks/70222.html</trackback:ping><description><![CDATA[<div style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; ">一个定义为volatile的变量是说这变量可能会被意想不到地改变，这样，编译器就不会去假设这个变量的值了。精确地说就是，优化器在用到这个变量时必须每次都小心地重新读取这个变量的值，而不是使用保存在寄存器里的备份。下面是volatile变量的几个例子：&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;1).&nbsp;并行设备的硬件寄存器（如：状态寄存器）&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;2).&nbsp;一个中断服务子程序中会访问到的非自动变量(Non-automatic&nbsp;variables)&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;3).&nbsp;多线程应用中被几个任务共享的变量&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;回答不出这个问题的人是不会被雇佣的。我认为这是区分C程序员和嵌入式系统程序员的最基本的问题。<span style="color: red; ">嵌入式系统程序员经常同硬件、中断、RTOS等等打交道</span>，所用这些都要求volatile变量。不懂得volatile内容将会带来灾难。&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;假设被面试者正确地回答了这几个问题（嗯，怀疑这是否会是这样），我将稍微深究一下，看一下这家伙是不是直正懂得volatile完全的重要性。&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;1).&nbsp;一个参数既可以是const还可以是volatile吗？解释为什么。&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;2).&nbsp;一个指针可以是volatile&nbsp;吗？解释为什么。&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;3).&nbsp;下面的函数有什么错误：&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;square(volatile&nbsp;int&nbsp;*ptr)&nbsp;<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;&nbsp;return&nbsp;*ptr&nbsp;*&nbsp;*ptr;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;下面是答案：&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;1).&nbsp;是的。一个例子是只读的状态寄存器。它是volatile因为它可能被意想不到地改变。它是const因为程序不应该试图去修改它。&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;2).&nbsp;是的。尽管这并不很常见。一个例子是当一个中断服务子程序修该一个指向一个buffer的指针时。&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;3).&nbsp;这段代码的有个恶作剧。这段代码的目的是用来返指针*ptr指向值的平方，但是，由于*ptr指向一个volatile型参数，编译器将产生类似下面的代码：&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;square(volatile&nbsp;int&nbsp;*ptr)&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;a,b;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a&nbsp;=&nbsp;*ptr;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b&nbsp;=&nbsp;*ptr;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;a&nbsp;*&nbsp;b;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;由于*ptr的值可能被意想不到地该变，因此a和b可能是不同的。结果，这段代码可能返不是你所期望的平方值！正确的代码如下：&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;long&nbsp;square(volatile&nbsp;int&nbsp;*ptr)&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;a;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a&nbsp;=&nbsp;*ptr;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;a&nbsp;*&nbsp;a;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;</div><div style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; ">讲讲我的理解：&nbsp;（欢迎打板子...~~！）&nbsp;<br /><br />关键在于两个地方：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;<br />1.&nbsp;编译器的优化&nbsp;&nbsp;(请高手帮我看看下面的理解)&nbsp;<br /><br />在本次线程内,&nbsp;当读取一个变量时，为提高存取速度，编译器优化时有时会先把变量读取到一个寄存器中；以后，再取变量值时，就直接从寄存器中取值；&nbsp;<br /><br />当变量值在本线程里改变时，会同时把变量的新值copy到该寄存器中，以便保持一致&nbsp;<br /><br />当变量在因别的线程等而改变了值，该寄存器的值不会相应改变，从而造成应用程序读取的值和实际的变量值不一致&nbsp;<br /><br />当该寄存器在因别的线程等而改变了值，原变量的值不会改变，从而造成应用程序读取的值和实际的变量值不一致&nbsp;&nbsp;<br /><br /><br />举一个不太准确的例子：&nbsp;&nbsp;<br /><br />发薪资时，会计每次都把员工叫来登记他们的银行卡号；一次会计为了省事，没有即时登记，用了以前登记的银行卡号；刚好一个员工的银行卡丢了，已挂失该银行卡号；从而造成该员工领不到工资&nbsp;&nbsp;<br /><br />员工&nbsp;－－&nbsp;原始变量地址&nbsp;&nbsp;<br />银行卡号&nbsp;－－&nbsp;原始变量在寄存器的备份&nbsp;&nbsp;<br /><br /><br />2.&nbsp;在什么情况下会出现(如1楼所说)&nbsp;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;1).&nbsp;并行设备的硬件寄存器（如：状态寄存器）&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;2).&nbsp;一个中断服务子程序中会访问到的非自动变量(Non-automatic&nbsp;variables)&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;3).&nbsp;多线程应用中被几个任务共享的变量&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><br />补充：&nbsp;volatile应该解释为&#8220;直接存取原始内存地址&#8221;比较合适，&#8220;易变的&#8221;这种解释简直有点误导人；</div><img src ="http://www.cnitblog.com/chenlei/aggbug/70222.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/chenlei/" target="_blank">Mr.雷</a> 2010-10-17 21:55 <a href="http://www.cnitblog.com/chenlei/archive/2010/10/17/70222.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>什么是带内信令和带外信令</title><link>http://www.cnitblog.com/chenlei/archive/2010/10/13/70076.html</link><dc:creator>Mr.雷</dc:creator><author>Mr.雷</author><pubDate>Wed, 13 Oct 2010 07:26:00 GMT</pubDate><guid>http://www.cnitblog.com/chenlei/archive/2010/10/13/70076.html</guid><wfw:comment>http://www.cnitblog.com/chenlei/comments/70076.html</wfw:comment><comments>http://www.cnitblog.com/chenlei/archive/2010/10/13/70076.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/chenlei/comments/commentRss/70076.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/chenlei/services/trackbacks/70076.html</trackback:ping><description><![CDATA[信令是交换机之间通信的语言，带外信令是指信令和语音信号的传输走不通的通道。<div><span  style="border-collapse: collapse; font-family: Helvetica, Arial, sans-serif; font-size: 14px; line-height: 22px; ">在很久很久以前（long long ago)，那时候人们还处于模拟通信和机械式交换机的时代（纵横或者步进），那时候不存在独立的信令网，交换机之间的&#8220;语言交流（信令）&#8221;和语音信号在一条传输通道上跑。这就是带内信令。后来发展了，交换机之间的&#8220;语言交流（信令）&#8221;和语音信号的传输分别走不同的传输通道，建立起独立的信令网，这样信令信号走信令网，语音走语音的传输通道，两者分道扬镳，这就是带外信令！</span></div><img src ="http://www.cnitblog.com/chenlei/aggbug/70076.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/chenlei/" target="_blank">Mr.雷</a> 2010-10-13 15:26 <a href="http://www.cnitblog.com/chenlei/archive/2010/10/13/70076.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>