﻿<?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++博客-woomsg</title><link>http://www.cppblog.com/woomsg/</link><description>在路上

</description><language>zh-cn</language><lastBuildDate>Mon, 13 Apr 2026 09:41:52 GMT</lastBuildDate><pubDate>Mon, 13 Apr 2026 09:41:52 GMT</pubDate><ttl>60</ttl><item><title>gloox代码分析4 - private xml storage</title><link>http://www.cppblog.com/woomsg/archive/2008/11/06/66144.html</link><dc:creator>ysong.lee</dc:creator><author>ysong.lee</author><pubDate>Thu, 06 Nov 2008 09:18:00 GMT</pubDate><guid>http://www.cppblog.com/woomsg/archive/2008/11/06/66144.html</guid><wfw:comment>http://www.cppblog.com/woomsg/comments/66144.html</wfw:comment><comments>http://www.cppblog.com/woomsg/archive/2008/11/06/66144.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/woomsg/comments/commentRss/66144.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/woomsg/services/trackbacks/66144.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 这部分的作用是客户端可以存放任意格式的私有xml数据到服务器上,并且在想要查看的时候取回!1.协议 - XEP-0049 - &nbsp;http://xmpp.org/extensions/xep-0049.html2. jabber client可以保存任意的xml数据到服务器，通过一个&lt;iq type="set"&gt;的请求.该请求需要包含一个名称空间为jabber:iq:priva...&nbsp;&nbsp;<a href='http://www.cppblog.com/woomsg/archive/2008/11/06/66144.html'>阅读全文</a><img src ="http://www.cppblog.com/woomsg/aggbug/66144.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/woomsg/" target="_blank">ysong.lee</a> 2008-11-06 17:18 <a href="http://www.cppblog.com/woomsg/archive/2008/11/06/66144.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>gloox代码分析3 - 注册模块</title><link>http://www.cppblog.com/woomsg/archive/2008/11/06/66098.html</link><dc:creator>ysong.lee</dc:creator><author>ysong.lee</author><pubDate>Thu, 06 Nov 2008 04:59:00 GMT</pubDate><guid>http://www.cppblog.com/woomsg/archive/2008/11/06/66098.html</guid><wfw:comment>http://www.cppblog.com/woomsg/comments/66098.html</wfw:comment><comments>http://www.cppblog.com/woomsg/archive/2008/11/06/66098.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cppblog.com/woomsg/comments/commentRss/66098.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/woomsg/services/trackbacks/66098.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: #jabber协议中如何注册一个用户？首先要与服务器建立一个连接, 在完成TLS握手之后就可以进行注册了,为什么不需要SASL握手呢?因为SASL握手只针对已经注册的用户在登陆服务器的时候使用.(修改密码和删除用户的时候需要SASL握手)下面以openfire作为服务器，注册一个用户的过程如下:(假设已经完成了TLS握手)1. ( C-&gt;S ) &lt;stream:stream &nbsp...&nbsp;&nbsp;<a href='http://www.cppblog.com/woomsg/archive/2008/11/06/66098.html'>阅读全文</a><img src ="http://www.cppblog.com/woomsg/aggbug/66098.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/woomsg/" target="_blank">ysong.lee</a> 2008-11-06 12:59 <a href="http://www.cppblog.com/woomsg/archive/2008/11/06/66098.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>openssl使用</title><link>http://www.cppblog.com/woomsg/archive/2008/11/03/64508.html</link><dc:creator>ysong.lee</dc:creator><author>ysong.lee</author><pubDate>Mon, 03 Nov 2008 06:08:00 GMT</pubDate><guid>http://www.cppblog.com/woomsg/archive/2008/11/03/64508.html</guid><wfw:comment>http://www.cppblog.com/woomsg/comments/64508.html</wfw:comment><comments>http://www.cppblog.com/woomsg/archive/2008/11/03/64508.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/woomsg/comments/commentRss/64508.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/woomsg/services/trackbacks/64508.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 1. websiteSSL(secure Socket Layer)TLS(transport Layer Security) - SSL3.0基础之上提出的安全通信标准,目前版本是1.0openssl 主页 -> http://www.openssl.org/openssl 中文文档 -> http://www.chinaunix.net/jh/13/478901.html 2. 如何编译O...&nbsp;&nbsp;<a href='http://www.cppblog.com/woomsg/archive/2008/11/03/64508.html'>阅读全文</a><img src ="http://www.cppblog.com/woomsg/aggbug/64508.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/woomsg/" target="_blank">ysong.lee</a> 2008-11-03 14:08 <a href="http://www.cppblog.com/woomsg/archive/2008/11/03/64508.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>如何利用jabber协议与gtalk服务器通讯 - 建立会话</title><link>http://www.cppblog.com/woomsg/archive/2008/10/29/65424.html</link><dc:creator>ysong.lee</dc:creator><author>ysong.lee</author><pubDate>Tue, 28 Oct 2008 16:29:00 GMT</pubDate><guid>http://www.cppblog.com/woomsg/archive/2008/10/29/65424.html</guid><wfw:comment>http://www.cppblog.com/woomsg/comments/65424.html</wfw:comment><comments>http://www.cppblog.com/woomsg/archive/2008/10/29/65424.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cppblog.com/woomsg/comments/commentRss/65424.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/woomsg/services/trackbacks/65424.html</trackback:ping><description><![CDATA[&nbsp;客户端与gtalk server建立会话的过程如下(默认中间没有错误发生):<br><br>1. ( C-&gt;S ) 连接到服务器, 发送'hello'信息.<br>&lt;stream:stream to="gmail.com" version="1.0" xmlns:stream="<a href="http://etherx.jabber.org/streams">http://etherx.jabber.org/streams</a>" xmlns="jabber:client"&gt;<br><br>2. ( S-&gt;C ) 服务器回应'hello'信息<br>&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br>&lt;stream:stream from="gmail.com" id="A9D1B4DB24EA879C" version="1.0" xmlns:stream="<a href="http://etherx.jabber.org/streams">http://etherx.jabber.org/streams</a>" xmlns="jabber:client"&gt;<br><br>3. ( S-&gt;C&nbsp;) 服务器要求TLS,&nbsp;SASL<br>&nbsp;&lt;stream:features&gt;<br>&nbsp; &lt;starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"&gt;&lt;required/&gt;&lt;/starttls&gt;<br>&nbsp; &lt;mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"&gt;<br>&nbsp;&nbsp;&nbsp; &lt;mechanism&gt;X-GOOGLE-TOKEN&lt;/mechanism&gt;<br>&nbsp; &lt;/mechanisms&gt;<br>&lt;/stream:features&gt;<br><br>4. ( C-&gt;S&nbsp;) 开始TLS<br>&lt;starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/&gt;<br><br>5. ( S-&gt;C&nbsp;) 服务器允许继续TLS<br>&lt;proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls"/&gt;<br><br>6. ( C-&gt;S&nbsp;) TLS握手<br>客户端向服务器发起TLS握手请求, 如果握手成功, 执行#7 (可以使用openssl实现TLS的握手功能)<br><br>7. ( C-&gt;S&nbsp;) TLS握手结束后, 发送新的'hello'消息<br>&lt;stream:stream to="gmail.com" version="1.0" xmlns:stream="<a href="http://etherx.jabber.org/streams">http://etherx.jabber.org/streams</a>" xmlns="jabber:client"&gt;<br><br>8. ( S-&gt;C&nbsp;) 服务器回应'hello'消息<br>&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br>&lt;stream:stream from="gmail.com" id="D38877BD862E0EE4" version="1.0" xmlns:stream="<a href="http://etherx.jabber.org/streams">http://etherx.jabber.org/streams</a>" xmlns="jabber:client"&gt;<br><br>9. ( S-&gt;C&nbsp;) 服务器要求SASL<br>&lt;stream:features&gt;<br>&nbsp; &lt;mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"&gt;<br>&nbsp;&nbsp;&nbsp; &lt;mechanism&gt;PLAIN&lt;/mechanism&gt;<br>&nbsp;&nbsp;&nbsp; &lt;mechanism&gt;X-GOOGLE-TOKEN&lt;/mechanism&gt;<br>&nbsp; &lt;/mechanisms&gt;<br>&lt;/stream:features&gt;<br><br>10. ( C-&gt;S&nbsp;) 客户端执行SASL<br>&lt;auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN"&gt;<br>&nbsp; AHlzb25nLmxlZUBnbWFpbC5jb20AeXNvbmdAMTk4NA==<br>&lt;/auth&gt;<br><br>auth的cdata的格式 '\0'+username+'\0'+password 的base64编码, username和password必须是经过认证的.<br>例如:<br>'\0' + <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#39;&#121;&#115;&#111;&#110;&#103;&#46;&#108;&#101;&#101;&#64;&#103;&#109;&#97;&#105;&#108;&#46;&#99;&#111;&#109;&#39;">'ysong.lee@gmail.com'</a>&nbsp;+ '\0' + 123456 -&gt; 经过base64编码处理后变为cdata<br><br>11. ( S-&gt;C&nbsp;) SASL成功<br>&lt;success xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/&gt;<br><br>12. ( C-&gt;S&nbsp;) 客户端发送新的'hello'消息<br>&lt;stream:stream to="gmail.com" version="1.0" xmlns:stream="<a href="http://etherx.jabber.org/streams">http://etherx.jabber.org/streams</a>" xmlns="jabber:client"&gt;<br><br>13. ( S-&gt;C&nbsp;) 服务器回应'hello'消息<br>&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br>&lt;stream:stream from="gmail.com" id="00035A2B998BF4B9" version="1.0" xmlns:stream="<a href="http://etherx.jabber.org/streams">http://etherx.jabber.org/streams</a>" xmlns="jabber:client"&gt;<br><br>14. ( S-&gt;C&nbsp;) 服务器要求绑定资源和建立一个会话<br>&lt;stream:features&gt;<br>&nbsp; &lt;bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/&gt;<br>&nbsp; &lt;session xmlns="urn:ietf:params:xml:ns:xmpp-session"/&gt;<br>&lt;/stream:features&gt;<br><br>15. ( C-&gt;S&nbsp;) 客户端绑定申请一个资源<br>&lt;iq type="set" id="1"&gt;&lt;bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/&gt;&lt;/iq&gt;<br><br>16. ( S-&gt;C&nbsp;) 服务器返回绑定资源的结果<br>&lt;iq id="1" type="result"&gt;<br>&nbsp; &lt;bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"&gt;<br>&nbsp;&nbsp;&nbsp; &lt;jid&gt;ysong.lee@gmail.com/BC20B630&lt;/jid&gt;<br>&nbsp; &lt;/bind&gt;<br>&lt;/iq&gt;<br><br>17. ( C-&gt;S&nbsp;) 客户端申请建立会话<br>&lt;iq type="set" id="2"&gt;<br>&nbsp; &lt;session xmlns="urn:ietf:params:xml:ns:xmpp-session"/&gt;<br>&lt;/iq&gt;<br><br>18. ( S-&gt;C&nbsp;) 服务器返回建立会话成功<br>&lt;iq type="result" id="2"/&gt;<br><br><br>到此, Client和Gtalk server的一个会话已经建立, 可以根据jabber协议进行其它操作. 请求联系人列表, 发消息等.<br><br><br>
<img src ="http://www.cppblog.com/woomsg/aggbug/65424.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/woomsg/" target="_blank">ysong.lee</a> 2008-10-29 00:29 <a href="http://www.cppblog.com/woomsg/archive/2008/10/29/65424.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>openssl使用(补)</title><link>http://www.cppblog.com/woomsg/archive/2008/10/22/64626.html</link><dc:creator>ysong.lee</dc:creator><author>ysong.lee</author><pubDate>Wed, 22 Oct 2008 02:48:00 GMT</pubDate><guid>http://www.cppblog.com/woomsg/archive/2008/10/22/64626.html</guid><wfw:comment>http://www.cppblog.com/woomsg/comments/64626.html</wfw:comment><comments>http://www.cppblog.com/woomsg/archive/2008/10/22/64626.html#Feedback</comments><slash:comments>10</slash:comments><wfw:commentRss>http://www.cppblog.com/woomsg/comments/commentRss/64626.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/woomsg/services/trackbacks/64626.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 1. 使用OpenSSL内置的数据结构BIO可以方便的创建安全和非安全链接,在IBM Web上的"使用OpenSSL进行安全编程"系列的三篇文章是个不错的入门:http://www.ibm.com/developerworks/cn/linux/l-openssl.htmlhttp://www.ibm.com/developerworks/cn/linux/l-openssl2.htmlhttp:...&nbsp;&nbsp;<a href='http://www.cppblog.com/woomsg/archive/2008/10/22/64626.html'>阅读全文</a><img src ="http://www.cppblog.com/woomsg/aggbug/64626.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/woomsg/" target="_blank">ysong.lee</a> 2008-10-22 10:48 <a href="http://www.cppblog.com/woomsg/archive/2008/10/22/64626.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>gloox代码分析2 - xml parser模块</title><link>http://www.cppblog.com/woomsg/archive/2008/10/18/64296.html</link><dc:creator>ysong.lee</dc:creator><author>ysong.lee</author><pubDate>Sat, 18 Oct 2008 06:51:00 GMT</pubDate><guid>http://www.cppblog.com/woomsg/archive/2008/10/18/64296.html</guid><wfw:comment>http://www.cppblog.com/woomsg/comments/64296.html</wfw:comment><comments>http://www.cppblog.com/woomsg/archive/2008/10/18/64296.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/woomsg/comments/commentRss/64296.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/woomsg/services/trackbacks/64296.html</trackback:ping><description><![CDATA[gloox自己实现了xml的解析模块，没有用到第三方的库(tinyXML，expat )<br>主要涉及的文件:<br>tag.h (tag.cpp)<br>taghandler.h<br>parser.h (parser.cpp)<br><br><strong>1. Tag一个Tag就是一个XML元素<br></strong>例如:<br>a. <br>&lt;book kind='computer'&gt;<br>&nbsp; &lt;store id='23'/&gt;<br>&nbsp; &lt;author&gt;<br>&nbsp;&nbsp;&nbsp; qiang<br>&nbsp; &lt;/author&gt;<br>&lt;/book&gt;<br>b. &lt;book id='32'/&gt;<br>c. &lt;book&gt;name1&lt;/book&gt;<br><br>首先介绍一个概念: escape-string，何为escape-string?<br>在escape-string中:<br>&nbsp;'&amp;'转换成&amp;amp;, '&lt;'转换成&amp;lt;, '&gt;'转换成&amp;gt;.<br>编码表如下:<br>//////////////////////////////////////////////////////////////////////////<br>// 编码表 （中间的空格去掉，这里只是为了方便显示）:<br>// -------------------------------------------------------<br>// | 字符&nbsp;&nbsp;&nbsp;&nbsp; | 十进制 | 十六进制 | THML字符集 | Unicode |<br>// -------------------------------------------------------<br>// | " 双引号 | &amp; # 34;&nbsp; | &amp; # x22;&nbsp;&nbsp; | "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | \u0022&nbsp; |<br>// -------------------------------------------------------<br>// | ' 单引号 | &amp; # 39;&nbsp; | &amp; # x27;&nbsp;&nbsp; | &amp; apos;&nbsp;&nbsp;&nbsp;&nbsp; | \u0027&nbsp; |<br>// -------------------------------------------------------<br>// | &amp; 与&nbsp;&nbsp;&nbsp;&nbsp; | &amp; # 38;&nbsp; | &amp; # x26;&nbsp;&nbsp; | &amp; amp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | \u0026&nbsp; |<br>// -------------------------------------------------------<br>// | &lt; 小于号 | &amp; # 60;&nbsp; | &amp; # x3C;&nbsp;&nbsp; | &amp; lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | \u003c&nbsp; |<br>// -------------------------------------------------------<br>// | &gt; 大于好 | &amp; # 62;&nbsp; | &amp; # x3E;&nbsp;&nbsp; | &amp; gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | \u003e&nbsp; |<br>// -------------------------------------------------------<br>gloox - APIs<br>Tag::escape()&nbsp;&nbsp;&nbsp; 功能: string -&gt; escape-string<br>Tag::relax()&nbsp; 功能: escape-string -&gt; string<br><br>主要成员变量:<br>attributes - 所有属性的list<br>name - 节点名字<br>cdata - 节点数据，例如&lt;name&gt;cdata&lt;/name&gt;中的cdata<br>children - 所有的子节点<br>parent - 父节点指针，如果没有则为空<br>bool incoming - 表示构造xml node的时候传入的字符串是否是escape-string，如果是，需要在构造的时候调用relex把escape-string转换成string.<br><br>主要方法:<br>也就是一些针对name\children\attributes\cdata进行增加\删除\修改的方法 <br>xml()方法返回该节点的一个完整的xml数据流<br>findTag和findTagList提供对XPath的支持.<br><br>例如:<br>屏幕将输出:<br>&lt;book kind='computer'&gt;&lt;store id='23'/&gt;&lt;author&gt;qiang&lt;/author&gt;&lt;/book&gt;<br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080">&nbsp;1</span><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">#include&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">iostream</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">&nbsp;2</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>#include&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">tag.h</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">&nbsp;3</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br></span><span style="COLOR: #008080">&nbsp;4</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>#pragma&nbsp;comment(&nbsp;lib,&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">gloox.lib</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;)<br></span><span style="COLOR: #008080">&nbsp;5</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">using</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">namespace</span><span style="COLOR: #000000">&nbsp;gloox;<br></span><span style="COLOR: #008080">&nbsp;6</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br></span><span style="COLOR: #008080">&nbsp;7</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;&lt;book&nbsp;kind='computer'&gt;<br></span><span style="COLOR: #008080">&nbsp;8</span><span style="COLOR: #008000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;&nbsp;&nbsp;&lt;store&nbsp;id='23'/&gt;<br></span><span style="COLOR: #008080">&nbsp;9</span><span style="COLOR: #008000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;&nbsp;&nbsp;&lt;author&gt;<br></span><span style="COLOR: #008080">10</span><span style="COLOR: #008000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;qiang<br></span><span style="COLOR: #008080">11</span><span style="COLOR: #008000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;&nbsp;&nbsp;&lt;/author&gt;<br></span><span style="COLOR: #008080">12</span><span style="COLOR: #008000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;&lt;/book&gt;<br></span><span style="COLOR: #008080">13</span><span style="COLOR: #008000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">//<br></span><span style="COLOR: #008080">14</span><span style="COLOR: #008000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">15</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br></span><span style="COLOR: #008080">16</span><span style="COLOR: #000000"><img id=Codehighlighter1_239_585_Open_Image onclick="this.style.display='none'; Codehighlighter1_239_585_Open_Text.style.display='none'; Codehighlighter1_239_585_Closed_Image.style.display='inline'; Codehighlighter1_239_585_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_239_585_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_239_585_Closed_Text.style.display='none'; Codehighlighter1_239_585_Open_Image.style.display='inline'; Codehighlighter1_239_585_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;main(&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;argc,&nbsp;</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">&nbsp;argv[]&nbsp;)&nbsp;</span><span id=Codehighlighter1_239_585_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_239_585_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">17</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;Tag</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">&nbsp;tag_book&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000">&nbsp;Tag(&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">book</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br></span><span style="COLOR: #008080">18</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;tag_book</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">addAttribute(&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">kind</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">computer</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;);<br></span><span style="COLOR: #008080">19</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;<br></span><span style="COLOR: #008080">20</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;Tag</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">&nbsp;tag_store&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000">&nbsp;Tag(&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">store</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;);<br></span><span style="COLOR: #008080">21</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;tag_store</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">addAttribute(&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">id</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">32</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;);<br></span><span style="COLOR: #008080">22</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br></span><span style="COLOR: #008080">23</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;Tag</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">&nbsp;tag_author&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000">&nbsp;Tag(&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">author</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">qiang</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;);<br></span><span style="COLOR: #008080">24</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br></span><span style="COLOR: #008080">25</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;tag_book</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">addChild(&nbsp;tag_store&nbsp;);<br></span><span style="COLOR: #008080">26</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;tag_book</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">addChild(&nbsp;tag_author&nbsp;);<br></span><span style="COLOR: #008080">27</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br></span><span style="COLOR: #008080">28</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;std::cout</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">tag_book</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">xml()</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">std::endl;<br></span><span style="COLOR: #008080">29</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">30</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span></div>
<br><strong>2. TagHandler是一个接收parser解析完成的tag的接口，继承该类，则可以接收parser解析的tag对象事件.</strong><br>只有一个接口<br>virtual void handleTag( Tag *tag ) = 0 - 接收解析完的tag<br><br>3. Parser一个XML解析器<br>提供的接口非常简洁，只需要一个TagHandler来构造，该handler接收并处理解析的tag，另外只有一个feed接口来填充数据.<br>要注意的是feed接口填充的数据必须是一个格式正确的xml，否则无法解析，也就是说parser不会判断xml的格式。<br><br>例如:<br>下面的例子中对feed来说分开填充和一次性填充数据的效果是一样的，也就是scenario1和scenario2的效果是一样的，这也刚好和上层应用中TCP 流处理的方式统一，对于接收到服务器端的XML流，无论是否完整，只需要直接feed就可以了。handlerTag方法将收到两个<br>xml tag解析完成的事件，分别来自scenario1和scenario2，屏幕将输出:<br>&lt;book kind='computer'&gt;&lt;store id='23'/&gt;&lt;author&gt;qiang&lt;/author&gt;&lt;/book&gt;&nbsp; <br>&lt;book kind='computer'&gt;&lt;store id='23'/&gt;&lt;author&gt;qiang&lt;/author&gt;&lt;/book&gt;<br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080">&nbsp;1</span><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">#include&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">iostream</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">&nbsp;2</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>#include&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">tag.h</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">&nbsp;3</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>#include&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">parser.h</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">&nbsp;4</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br></span><span style="COLOR: #008080">&nbsp;5</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>#pragma&nbsp;comment(&nbsp;lib,&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">gloox.lib</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;)<br></span><span style="COLOR: #008080">&nbsp;6</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">using</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">namespace</span><span style="COLOR: #000000">&nbsp;gloox;<br></span><span style="COLOR: #008080">&nbsp;7</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br></span><span style="COLOR: #008080">&nbsp;8</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;&lt;book&nbsp;kind='computer'&gt;<br></span><span style="COLOR: #008080">&nbsp;9</span><span style="COLOR: #008000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;&nbsp;&nbsp;&lt;store&nbsp;id='23'/&gt;<br></span><span style="COLOR: #008080">10</span><span style="COLOR: #008000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;&nbsp;&nbsp;&lt;author&gt;<br></span><span style="COLOR: #008080">11</span><span style="COLOR: #008000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;qiang<br></span><span style="COLOR: #008080">12</span><span style="COLOR: #008000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;&nbsp;&nbsp;&lt;/author&gt;<br></span><span style="COLOR: #008080">13</span><span style="COLOR: #008000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;&lt;/book&gt;<br></span><span style="COLOR: #008080">14</span><span style="COLOR: #008000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">15</span><span style="COLOR: #008000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">//<br></span><span style="COLOR: #008080">16</span><span style="COLOR: #008000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">17</span><span style="COLOR: #000000"><img id=Codehighlighter1_267_803_Open_Image onclick="this.style.display='none'; Codehighlighter1_267_803_Open_Text.style.display='none'; Codehighlighter1_267_803_Closed_Image.style.display='inline'; Codehighlighter1_267_803_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_267_803_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_267_803_Closed_Text.style.display='none'; Codehighlighter1_267_803_Open_Image.style.display='inline'; Codehighlighter1_267_803_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000">&nbsp;TagHandlerImpl&nbsp;:&nbsp;</span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">&nbsp;TagHandler&nbsp;</span><span id=Codehighlighter1_267_803_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_267_803_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">18</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">:<br></span><span style="COLOR: #008080">19</span><span style="COLOR: #000000"><img id=Codehighlighter1_296_297_Open_Image onclick="this.style.display='none'; Codehighlighter1_296_297_Open_Text.style.display='none'; Codehighlighter1_296_297_Closed_Image.style.display='inline'; Codehighlighter1_296_297_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_296_297_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_296_297_Closed_Text.style.display='none'; Codehighlighter1_296_297_Open_Image.style.display='inline'; Codehighlighter1_296_297_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #000000">~</span><span style="COLOR: #000000">TagHandlerImpl()&nbsp;</span><span id=Codehighlighter1_296_297_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_296_297_Open_Text><span style="COLOR: #000000">{}</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">20</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br></span><span style="COLOR: #008080">21</span><span style="COLOR: #000000"><img id=Codehighlighter1_312_730_Open_Image onclick="this.style.display='none'; Codehighlighter1_312_730_Open_Text.style.display='none'; Codehighlighter1_312_730_Closed_Image.style.display='inline'; Codehighlighter1_312_730_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_312_730_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_312_730_Closed_Text.style.display='none'; Codehighlighter1_312_730_Open_Image.style.display='inline'; Codehighlighter1_312_730_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;run()&nbsp;</span><span id=Codehighlighter1_312_730_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_312_730_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">22</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Parser</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">&nbsp;parser&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000">&nbsp;Parser(</span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">);<br></span><span style="COLOR: #008080">23</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;scenario1</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">24</span><span style="COLOR: #008000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::</span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000">&nbsp;data&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&lt;book&nbsp;kind='computer'&gt;&lt;store&nbsp;id='23'/&gt;&lt;author&gt;qiang&lt;/author&gt;&lt;/book&gt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">25</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parser</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">feed(&nbsp;data&nbsp;);<br></span><span style="COLOR: #008080">26</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br></span><span style="COLOR: #008080">27</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;scenario2</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">28</span><span style="COLOR: #008000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::</span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000">&nbsp;data1&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&lt;book&nbsp;kind='computer</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">29</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::</span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000">&nbsp;data2&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">'&gt;&lt;store&nbsp;id='23'/&gt;&lt;auth</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">30</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::</span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000">&nbsp;data3&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">or&gt;qiang&lt;/author&gt;&lt;/book&gt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">31</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parser</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">feed(&nbsp;data1&nbsp;);<br></span><span style="COLOR: #008080">32</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parser</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">feed(&nbsp;data2&nbsp;);<br></span><span style="COLOR: #008080">33</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parser</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">feed(&nbsp;data3&nbsp;);<br></span><span style="COLOR: #008080">34</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">35</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br></span><span style="COLOR: #008080">36</span><span style="COLOR: #000000"><img id=Codehighlighter1_761_801_Open_Image onclick="this.style.display='none'; Codehighlighter1_761_801_Open_Text.style.display='none'; Codehighlighter1_761_801_Closed_Image.style.display='inline'; Codehighlighter1_761_801_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_761_801_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_761_801_Closed_Text.style.display='none'; Codehighlighter1_761_801_Open_Image.style.display='inline'; Codehighlighter1_761_801_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;handleTag(&nbsp;Tag&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">tag&nbsp;)&nbsp;</span><span id=Codehighlighter1_761_801_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_761_801_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">37</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::cout</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">tag</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">xml()</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">std::endl;<br></span><span style="COLOR: #008080">38</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">39</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">40</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br></span><span style="COLOR: #008080">41</span><span style="COLOR: #000000"><img id=Codehighlighter1_842_939_Open_Image onclick="this.style.display='none'; Codehighlighter1_842_939_Open_Text.style.display='none'; Codehighlighter1_842_939_Closed_Image.style.display='inline'; Codehighlighter1_842_939_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_842_939_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_842_939_Closed_Text.style.display='none'; Codehighlighter1_842_939_Open_Image.style.display='inline'; Codehighlighter1_842_939_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;main(&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;argc,&nbsp;</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">&nbsp;argv[]&nbsp;)&nbsp;</span><span id=Codehighlighter1_842_939_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_842_939_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">42</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;TagHandlerImpl</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">&nbsp;taghandlerImpl&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000">&nbsp;TagHandlerImpl();<br></span><span style="COLOR: #008080">43</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;taghandlerImpl</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">run();<br></span><span style="COLOR: #008080">44</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br></span><span style="COLOR: #008080">45</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">46</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span></div>
<br><br>
<img src ="http://www.cppblog.com/woomsg/aggbug/64296.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/woomsg/" target="_blank">ysong.lee</a> 2008-10-18 14:51 <a href="http://www.cppblog.com/woomsg/archive/2008/10/18/64296.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>gloox代码分析1 - connect模块</title><link>http://www.cppblog.com/woomsg/archive/2008/10/17/64260.html</link><dc:creator>ysong.lee</dc:creator><author>ysong.lee</author><pubDate>Fri, 17 Oct 2008 13:20:00 GMT</pubDate><guid>http://www.cppblog.com/woomsg/archive/2008/10/17/64260.html</guid><wfw:comment>http://www.cppblog.com/woomsg/comments/64260.html</wfw:comment><comments>http://www.cppblog.com/woomsg/archive/2008/10/17/64260.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/woomsg/comments/commentRss/64260.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/woomsg/services/trackbacks/64260.html</trackback:ping><description><![CDATA[主要分析gloox的connect模块，涉及的文件:<br>connectionbase.h<br>connectiondatahander.h<br>connectionhandler.h<br>connectiontcpbase.h (connectiontcpbase.cpp)<br>connectiontcpclient.h (connectiontcpclient.cpp)<br>connectiontcpserver.h (connectiontcpserver.cpp)<br><br><strong>1. ConnectionBase抽象连接类，表示一个socket连接。</strong><br>3个数据成员:<br>server和ip - 需要连接到的目标地址和端口(在ConnectionTcpServer是要绑定的本地地址)<br>connectionState - 连接的当前状态 (一个三种状态disconnected | connecting | connected)<br>connectionDataHandler - 处理三类ConnectionBase中的三类事件 ( 数据接收 | 连接建立 | 连接断开&nbsp;)<br>5个主要方法:<br>connect - 建立一个socket连接<br>disconnect - 断开一个socket连接<br>send - 发送数据，该方法直到要发送的数据全部发送完毕才返回<br>recv( int timeout&nbsp;) - 接收数据，接收到数据或者timeout返回<br>receive - 把connection设置成"接收模式"，也就是循环的调用recv接收数据，直到连接断开该方法返回，<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 该方法保证这个连接可以循环的接收数据.<br><br>注意: recv和receive的区别。<br><br><br><strong>2. ConnectionDataHandler处理继承自ConnectionBase的对象的事件</strong><br>handlerReceivedData - 接收到数据<br>handlerConnect - 一个原始的套接字连接建立<br>handlerDisconnect - 一个原始的套接字连接断开<br><br><strong>3. ConnectionTcpBase一个基本的TCP连接，继承自ConnectionBase</strong><br>数据成员<br>bool cancel - 表示连接是否应该断开，默认为true. (true表示连接断开)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 函数disconnect也就是仅仅设置cancel为true.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 在函数receive循环接收数据的逻辑中会检测cancel，如果为true，则表示连接断开，则返回，退出"接收模式"<br>int bufSize - buf的大小，默认是1024<br>char* buf - 缓冲区，大小事bufSize + 1 (在ConnectionTcpBase中并没有用到这个缓冲区，供上层使用E.g. ConnectionTcpClient的recv来接收数据)<br><br>实现的主要方法:<br>send - 发送数据<br>receive - "循环"接收数据<br>dataAvailable( int timeout&nbsp;) - 一个私有方法，作用是测试socket上目前是否有数据可读，如果有返回true.&nbsp;可以供recv调用. 避免了阻塞的调用原始套接字方法::receive或者::accept.<br><br><strong>4. ConnectionTcpClient实现一个基本的TCP连接，继承自ConnectionTcpBase</strong><br>实现的主要方法<br>connect - 连接到目标地址，如果成功，则调用handler-&gt;handlerConnect，失败则调用handler-&gt;handlerDisconnect<br>recv - 接收数据，如果接收到数据，马上调用handler-&gt;handlerReceiveData，接收发生错误，表示连接断开，调用handler-&gt;handlerDisconnect<br><br><strong>5. ConnectionHandler一个抽象类，用来接收一个客户端连接的请求，该类用于ConnectionTcpServer<br></strong>只有一个接口:<br>handleIncomingConnection( ConnectionBase *connect&nbsp;) - &amp;connect表示新建立的连接请求，哪原始的socket做类比相当于accept返回的socket.<br><br>注意: 区别于ConnectionDataHandler用于处理一个特定连接的中的事件(数据到来，连接断开，连接建立)，ConnectionListener用于XMPP Stream.<br><br><strong>6. ConnectionTcpServer，实质上就是一个侦听socket，同原始的socket做类比就是一个调用了bind/listen之后处于侦听状态的socket.</strong><br>主要数据成员:<br>connectionHandler - 接收新到来的连接，接收到之后调用handlerIncomingConnection<br>主要方法:<br>connect -&nbsp;建立套接字，绑定到本地地址，侦听bind/listen<br>recv - 调用accept接收一个socket连接，如果成功，则用accpet返回的socket创建一个ConnectionTCPClient，调用handlerIncomingConnection来处理新进的连接.<br><br>总结:<br>ConnectionTcpServer和ConnectionTcpClient的区别:<br>connect (client) -&nbsp;连接到服务器，使connection处于可以接收数据的状态<br>connect(server) - 绑定到本地地址，侦听，使connection处于可以接收新连接的状态(accept)<br><br>recv(client) - 接收数据，调用connectionDataHandler-&gt;handlerReceivedData<br>recv(server) - 接收新连接，调用connectionHandler-&gt;handlerIncomingConnection<br><br>receive(Client) - 接收数据状态，循环接收数据，调用disconnect时退出<br>receive(Server) - 接收连接状态，循环接收连接，调用disconnect时退出.<br><br>所以ConnectionTcpClient有发送数据和循环接收数据的能力，ConnectionTcpServer有侦听客户端连接的能力。当有特定的事件发生的时候，会自动触发相关的handler来进行处理，如数据到来，连接建立\断开，新连接到来等等。<br><br>问题:<br>这种设计模式使receive处于一个无限的while循环，不断的调用select+accpet或者select+receive，是否利于send之类的方法在同一个socket上发送数据?<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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
<img src ="http://www.cppblog.com/woomsg/aggbug/64260.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/woomsg/" target="_blank">ysong.lee</a> 2008-10-17 21:20 <a href="http://www.cppblog.com/woomsg/archive/2008/10/17/64260.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>如何在windows编译gloox</title><link>http://www.cppblog.com/woomsg/archive/2008/10/16/64200.html</link><dc:creator>ysong.lee</dc:creator><author>ysong.lee</author><pubDate>Thu, 16 Oct 2008 12:42:00 GMT</pubDate><guid>http://www.cppblog.com/woomsg/archive/2008/10/16/64200.html</guid><wfw:comment>http://www.cppblog.com/woomsg/comments/64200.html</wfw:comment><comments>http://www.cppblog.com/woomsg/archive/2008/10/16/64200.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/woomsg/comments/commentRss/64200.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/woomsg/services/trackbacks/64200.html</trackback:ping><description><![CDATA[1. Enviroment<br>&nbsp;"gloox - 0.9.9.5" + "Windows Server 2008" + "VC++ 2008"<br><br>2. config.h.win<br>HAVE_WINTLS<br>HAVE_WINDNS_H<br>HAVE_SETSOCKOPT<br><br>默认编译的时候出错:<br>dns.obj : error LNK2019: unresolved external symbol <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#95;&#68;&#110;&#115;&#70;&#114;&#101;&#101;&#64;&#56;"><font color=#003366>_DnsFree@8</font></a> referenced in function "public: static class std::map&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,int,struct std::less&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &gt;,class std::allocator&lt;struct std::pair&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const ,int&gt; &gt; &gt; __cdecl gloox::DNS::resolve(class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const &amp;,class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const &amp;,class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const &amp;,class gloox::LogSink const &amp;)" (<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#63;&#114;&#101;&#115;&#111;&#108;&#118;&#101;&#64;&#68;&#78;&#83;&#64;&#103;&#108;&#111;&#111;&#120;&#64;&#64;&#83;&#65;&#63;&#65;&#86;&#63;&#36;&#109;&#97;&#112;&#64;&#86;&#63;&#36;&#98;&#97;&#115;&#105;&#99;&#95;&#115;&#116;&#114;&#105;&#110;&#103;&#64;&#68;&#85;&#63;&#36;&#99;&#104;&#97;&#114;&#95;&#116;&#114;&#97;&#105;&#116;&#115;&#64;&#68;&#64;&#115;&#116;&#100;&#64;&#64;&#86;&#63;&#36;&#97;&#108;&#108;&#111;&#99;&#97;&#116;&#111;&#114;&#64;&#68;&#64;&#50;&#64;&#64;&#115;&#116;&#100;&#64;&#64;&#72;&#85;&#63;&#36;&#108;&#101;&#115;&#115;&#64;&#86;&#63;&#36;&#98;&#97;&#115;&#105;&#99;&#95;&#115;&#116;&#114;&#105;&#110;&#103;&#64;&#68;&#85;&#63;&#36;&#99;&#104;&#97;&#114;&#95;&#116;&#114;&#97;&#105;&#116;&#115;&#64;&#68;&#64;&#115;&#116;&#100;&#64;&#64;&#86;&#63;&#36;&#97;&#108;&#108;&#111;&#99;&#97;&#116;&#111;&#114;&#64;&#68;&#64;&#50;&#64;&#64;&#115;&#116;&#100;&#64;&#64;&#64;&#50;&#64;&#86;&#63;&#36;&#97;&#108;&#108;&#111;&#99;&#97;&#116;&#111;&#114;&#64;&#85;&#63;&#36;&#112;&#97;&#105;&#114;&#64;&#36;&#36;&#67;&#66;&#86;&#63;&#36;&#98;&#97;&#115;&#105;&#99;&#95;&#115;&#116;&#114;&#105;&#110;&#103;&#64;&#68;&#85;&#63;&#36;&#99;&#104;&#97;&#114;&#95;&#116;&#114;&#97;&#105;&#116;&#115;&#64;&#68;&#64;&#115;&#116;&#100;&#64;&#64;&#86;&#63;&#36;&#97;&#108;&#108;&#111;&#99;&#97;&#116;&#111;&#114;&#64;&#68;&#64;&#50;&#64;&#64;&#115;&#116;&#100;&#64;&#64;&#72;&#64;&#115;&#116;&#100;&#64;&#64;&#64;&#50;&#64;&#64;&#115;&#116;&#100;&#64;&#64;&#65;&#66;&#86;&#63;&#36;&#98;&#97;&#115;&#105;&#99;&#95;&#115;&#116;&#114;&#105;&#110;&#103;&#64;&#68;&#85;&#63;&#36;&#99;&#104;&#97;&#114;&#95;&#116;&#114;&#97;&#105;&#116;&#115;&#64;&#68;&#64;&#115;&#116;&#100;&#64;&#64;&#86;&#63;&#36;&#97;&#108;&#108;&#111;&#99;&#97;&#116;&#111;&#114;&#64;&#68;&#64;&#50;&#64;&#64;&#52;&#64;&#48;&#48;&#65;&#66;&#86;&#76;&#111;&#103;&#83;&#105;&#110;&#107;&#64;&#50;&#64;&#64;&#90;"><font color=#003366>?resolve@DNS@gloox@@SA?AV?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@HU?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@std@@@2@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@4@00ABVLogSink@2@@Z</font></a>)<br>dns.obj : error LNK2019: unresolved external symbol <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#95;&#68;&#110;&#115;&#81;&#117;&#101;&#114;&#121;&#95;&#65;&#64;&#50;&#52;"><font color=#003366>_DnsQuery_A@24</font></a> referenced in function "public: static class std::map&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,int,struct std::less&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &gt;,class std::allocator&lt;struct std::pair&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const ,int&gt; &gt; &gt; __cdecl gloox::DNS::resolve(class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const &amp;,class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const &amp;,class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const &amp;,class gloox::LogSink const &amp;)" (<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#63;&#114;&#101;&#115;&#111;&#108;&#118;&#101;&#64;&#68;&#78;&#83;&#64;&#103;&#108;&#111;&#111;&#120;&#64;&#64;&#83;&#65;&#63;&#65;&#86;&#63;&#36;&#109;&#97;&#112;&#64;&#86;&#63;&#36;&#98;&#97;&#115;&#105;&#99;&#95;&#115;&#116;&#114;&#105;&#110;&#103;&#64;&#68;&#85;&#63;&#36;&#99;&#104;&#97;&#114;&#95;&#116;&#114;&#97;&#105;&#116;&#115;&#64;&#68;&#64;&#115;&#116;&#100;&#64;&#64;&#86;&#63;&#36;&#97;&#108;&#108;&#111;&#99;&#97;&#116;&#111;&#114;&#64;&#68;&#64;&#50;&#64;&#64;&#115;&#116;&#100;&#64;&#64;&#72;&#85;&#63;&#36;&#108;&#101;&#115;&#115;&#64;&#86;&#63;&#36;&#98;&#97;&#115;&#105;&#99;&#95;&#115;&#116;&#114;&#105;&#110;&#103;&#64;&#68;&#85;&#63;&#36;&#99;&#104;&#97;&#114;&#95;&#116;&#114;&#97;&#105;&#116;&#115;&#64;&#68;&#64;&#115;&#116;&#100;&#64;&#64;&#86;&#63;&#36;&#97;&#108;&#108;&#111;&#99;&#97;&#116;&#111;&#114;&#64;&#68;&#64;&#50;&#64;&#64;&#115;&#116;&#100;&#64;&#64;&#64;&#50;&#64;&#86;&#63;&#36;&#97;&#108;&#108;&#111;&#99;&#97;&#116;&#111;&#114;&#64;&#85;&#63;&#36;&#112;&#97;&#105;&#114;&#64;&#36;&#36;&#67;&#66;&#86;&#63;&#36;&#98;&#97;&#115;&#105;&#99;&#95;&#115;&#116;&#114;&#105;&#110;&#103;&#64;&#68;&#85;&#63;&#36;&#99;&#104;&#97;&#114;&#95;&#116;&#114;&#97;&#105;&#116;&#115;&#64;&#68;&#64;&#115;&#116;&#100;&#64;&#64;&#86;&#63;&#36;&#97;&#108;&#108;&#111;&#99;&#97;&#116;&#111;&#114;&#64;&#68;&#64;&#50;&#64;&#64;&#115;&#116;&#100;&#64;&#64;&#72;&#64;&#115;&#116;&#100;&#64;&#64;&#64;&#50;&#64;&#64;&#115;&#116;&#100;&#64;&#64;&#65;&#66;&#86;&#63;&#36;&#98;&#97;&#115;&#105;&#99;&#95;&#115;&#116;&#114;&#105;&#110;&#103;&#64;&#68;&#85;&#63;&#36;&#99;&#104;&#97;&#114;&#95;&#116;&#114;&#97;&#105;&#116;&#115;&#64;&#68;&#64;&#115;&#116;&#100;&#64;&#64;&#86;&#63;&#36;&#97;&#108;&#108;&#111;&#99;&#97;&#116;&#111;&#114;&#64;&#68;&#64;&#50;&#64;&#64;&#52;&#64;&#48;&#48;&#65;&#66;&#86;&#76;&#111;&#103;&#83;&#105;&#110;&#107;&#64;&#50;&#64;&#64;&#90;"><font color=#003366>?resolve@DNS@gloox@@SA?AV?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@HU?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@std@@@2@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@4@00ABVLogSink@2@@Z</font></a>)<br>tlsschannel.obj : error LNK2019: unresolved external symbol <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#95;&#69;&#110;&#99;&#114;&#121;&#112;&#116;&#77;&#101;&#115;&#115;&#97;&#103;&#101;&#64;&#49;&#54;"><font color=#003366>_EncryptMessage@16</font></a> referenced in function "public: virtual bool __thiscall gloox::SChannel::encrypt(class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const &amp;)" (<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#63;&#101;&#110;&#99;&#114;&#121;&#112;&#116;&#64;&#83;&#67;&#104;&#97;&#110;&#110;&#101;&#108;&#64;&#103;&#108;&#111;&#111;&#120;&#64;&#64;&#85;&#65;&#69;&#95;&#78;&#65;&#66;&#86;&#63;&#36;&#98;&#97;&#115;&#105;&#99;&#95;&#115;&#116;&#114;&#105;&#110;&#103;&#64;&#68;&#85;&#63;&#36;&#99;&#104;&#97;&#114;&#95;&#116;&#114;&#97;&#105;&#116;&#115;&#64;&#68;&#64;&#115;&#116;&#100;&#64;&#64;&#86;&#63;&#36;&#97;&#108;&#108;&#111;&#99;&#97;&#116;&#111;&#114;&#64;&#68;&#64;&#50;&#64;&#64;&#115;&#116;&#100;&#64;&#64;&#64;&#90;"><font color=#003366>?encrypt@SChannel@gloox@@UAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z</font></a>)<br>tlsschannel.obj : error LNK2019: unresolved external symbol <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#95;&#68;&#101;&#99;&#114;&#121;&#112;&#116;&#77;&#101;&#115;&#115;&#97;&#103;&#101;&#64;&#49;&#54;"><font color=#003366>_DecryptMessage@16</font></a> referenced in function "public: virtual int __thiscall gloox::SChannel::decrypt(class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const &amp;)" (<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#63;&#100;&#101;&#99;&#114;&#121;&#112;&#116;&#64;&#83;&#67;&#104;&#97;&#110;&#110;&#101;&#108;&#64;&#103;&#108;&#111;&#111;&#120;&#64;&#64;&#85;&#65;&#69;&#72;&#65;&#66;&#86;&#63;&#36;&#98;&#97;&#115;&#105;&#99;&#95;&#115;&#116;&#114;&#105;&#110;&#103;&#64;&#68;&#85;&#63;&#36;&#99;&#104;&#97;&#114;&#95;&#116;&#114;&#97;&#105;&#116;&#115;&#64;&#68;&#64;&#115;&#116;&#100;&#64;&#64;&#86;&#63;&#36;&#97;&#108;&#108;&#111;&#99;&#97;&#116;&#111;&#114;&#64;&#68;&#64;&#50;&#64;&#64;&#115;&#116;&#100;&#64;&#64;&#64;&#90;"><font color=#003366>?decrypt@SChannel@gloox@@UAEHABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z</font></a>)<br>tlsschannel.obj : error LNK2019: unresolved external symbol <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#95;&#95;&#105;&#109;&#112;&#95;&#95;&#70;&#114;&#101;&#101;&#67;&#114;&#101;&#100;&#101;&#110;&#116;&#105;&#97;&#108;&#115;&#72;&#97;&#110;&#100;&#108;&#101;&#64;&#52;"><font color=#003366>__imp__FreeCredentialsHandle@4</font></a> referenced in function "public: virtual void __thiscall gloox::SChannel::cleanup(void)" (<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#63;&#99;&#108;&#101;&#97;&#110;&#117;&#112;&#64;&#83;&#67;&#104;&#97;&#110;&#110;&#101;&#108;&#64;&#103;&#108;&#111;&#111;&#120;&#64;&#64;&#85;&#65;&#69;&#88;&#88;&#90;"><font color=#003366>?cleanup@SChannel@gloox@@UAEXXZ</font></a>)<br>tlsschannel.obj : error LNK2019: unresolved external symbol <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#95;&#95;&#105;&#109;&#112;&#95;&#95;&#68;&#101;&#108;&#101;&#116;&#101;&#83;&#101;&#99;&#117;&#114;&#105;&#116;&#121;&#67;&#111;&#110;&#116;&#101;&#120;&#116;&#64;&#52;"><font color=#003366>__imp__DeleteSecurityContext@4</font></a> referenced in function "public: virtual void __thiscall gloox::SChannel::cleanup(void)" (<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#63;&#99;&#108;&#101;&#97;&#110;&#117;&#112;&#64;&#83;&#67;&#104;&#97;&#110;&#110;&#101;&#108;&#64;&#103;&#108;&#111;&#111;&#120;&#64;&#64;&#85;&#65;&#69;&#88;&#88;&#90;"><font color=#003366>?cleanup@SChannel@gloox@@UAEXXZ</font></a>)<br>tlsschannel.obj : error LNK2019: unresolved external symbol <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#95;&#70;&#114;&#101;&#101;&#67;&#111;&#110;&#116;&#101;&#120;&#116;&#66;&#117;&#102;&#102;&#101;&#114;&#64;&#52;"><font color=#003366>_FreeContextBuffer@4</font></a> referenced in function "public: virtual bool __thiscall gloox::SChannel::handshake(void)" (<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#63;&#104;&#97;&#110;&#100;&#115;&#104;&#97;&#107;&#101;&#64;&#83;&#67;&#104;&#97;&#110;&#110;&#101;&#108;&#64;&#103;&#108;&#111;&#111;&#120;&#64;&#64;&#85;&#65;&#69;&#95;&#78;&#88;&#90;"><font color=#003366>?handshake@SChannel@gloox@@UAE_NXZ</font></a>)<br>tlsschannel.obj : error LNK2019: unresolved external symbol <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#95;&#73;&#110;&#105;&#116;&#105;&#97;&#108;&#105;&#122;&#101;&#83;&#101;&#99;&#117;&#114;&#105;&#116;&#121;&#67;&#111;&#110;&#116;&#101;&#120;&#116;&#65;&#64;&#52;&#56;"><font color=#003366>_InitializeSecurityContextA@48</font></a> referenced in function "public: virtual bool __thiscall gloox::SChannel::handshake(void)" (<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#63;&#104;&#97;&#110;&#100;&#115;&#104;&#97;&#107;&#101;&#64;&#83;&#67;&#104;&#97;&#110;&#110;&#101;&#108;&#64;&#103;&#108;&#111;&#111;&#120;&#64;&#64;&#85;&#65;&#69;&#95;&#78;&#88;&#90;"><font color=#003366>?handshake@SChannel@gloox@@UAE_NXZ</font></a>)<br>tlsschannel.obj : error LNK2019: unresolved external symbol <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#95;&#65;&#99;&#113;&#117;&#105;&#114;&#101;&#67;&#114;&#101;&#100;&#101;&#110;&#116;&#105;&#97;&#108;&#115;&#72;&#97;&#110;&#100;&#108;&#101;&#65;&#64;&#51;&#54;"><font color=#003366>_AcquireCredentialsHandleA@36</font></a> referenced in function "public: virtual bool __thiscall gloox::SChannel::handshake(void)" (<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#63;&#104;&#97;&#110;&#100;&#115;&#104;&#97;&#107;&#101;&#64;&#83;&#67;&#104;&#97;&#110;&#110;&#101;&#108;&#64;&#103;&#108;&#111;&#111;&#120;&#64;&#64;&#85;&#65;&#69;&#95;&#78;&#88;&#90;"><font color=#003366>?handshake@SChannel@gloox@@UAE_NXZ</font></a>)<br>tlsschannel.obj : error LNK2019: unresolved external symbol <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#95;&#81;&#117;&#101;&#114;&#121;&#67;&#111;&#110;&#116;&#101;&#120;&#116;&#65;&#116;&#116;&#114;&#105;&#98;&#117;&#116;&#101;&#115;&#65;&#64;&#49;&#50;"><font color=#003366>_QueryContextAttributesA@12</font></a> referenced in function "private: void __thiscall gloox::SChannel::setSizes(void)" (<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#63;&#115;&#101;&#116;&#83;&#105;&#122;&#101;&#115;&#64;&#83;&#67;&#104;&#97;&#110;&#110;&#101;&#108;&#64;&#103;&#108;&#111;&#111;&#120;&#64;&#64;&#65;&#65;&#69;&#88;&#88;&#90;"><font color=#003366>?setSizes@SChannel@gloox@@AAEXXZ</font></a>)<br>tlsschannel.obj : error LNK2019: unresolved external symbol <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#95;&#95;&#105;&#109;&#112;&#95;&#95;&#67;&#101;&#114;&#116;&#70;&#114;&#101;&#101;&#67;&#101;&#114;&#116;&#105;&#102;&#105;&#99;&#97;&#116;&#101;&#67;&#104;&#97;&#105;&#110;&#64;&#52;"><font color=#003366>__imp__CertFreeCertificateChain@4</font></a> referenced in function "private: void __thiscall gloox::SChannel::validateCert(void)" (<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#63;&#118;&#97;&#108;&#105;&#100;&#97;&#116;&#101;&#67;&#101;&#114;&#116;&#64;&#83;&#67;&#104;&#97;&#110;&#110;&#101;&#108;&#64;&#103;&#108;&#111;&#111;&#120;&#64;&#64;&#65;&#65;&#69;&#88;&#88;&#90;"><font color=#003366>?validateCert@SChannel@gloox@@AAEXXZ</font></a>)<br>tlsschannel.obj : error LNK2019: unresolved external symbol <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#95;&#95;&#105;&#109;&#112;&#95;&#95;&#67;&#101;&#114;&#116;&#86;&#101;&#114;&#105;&#102;&#121;&#67;&#101;&#114;&#116;&#105;&#102;&#105;&#99;&#97;&#116;&#101;&#67;&#104;&#97;&#105;&#110;&#80;&#111;&#108;&#105;&#99;&#121;&#64;&#49;&#54;"><font color=#003366>__imp__CertVerifyCertificateChainPolicy@16</font></a> referenced in function "private: void __thiscall gloox::SChannel::validateCert(void)" (<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#63;&#118;&#97;&#108;&#105;&#100;&#97;&#116;&#101;&#67;&#101;&#114;&#116;&#64;&#83;&#67;&#104;&#97;&#110;&#110;&#101;&#108;&#64;&#103;&#108;&#111;&#111;&#120;&#64;&#64;&#65;&#65;&#69;&#88;&#88;&#90;"><font color=#003366>?validateCert@SChannel@gloox@@AAEXXZ</font></a>)<br>tlsschannel.obj : error LNK2019: unresolved external symbol <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#95;&#95;&#105;&#109;&#112;&#95;&#95;&#67;&#101;&#114;&#116;&#71;&#101;&#116;&#67;&#101;&#114;&#116;&#105;&#102;&#105;&#99;&#97;&#116;&#101;&#67;&#104;&#97;&#105;&#110;&#64;&#51;&#50;"><font color=#003366>__imp__CertGetCertificateChain@32</font></a> referenced in function "private: void __thiscall gloox::SChannel::validateCert(void)" (<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#63;&#118;&#97;&#108;&#105;&#100;&#97;&#116;&#101;&#67;&#101;&#114;&#116;&#64;&#83;&#67;&#104;&#97;&#110;&#110;&#101;&#108;&#64;&#103;&#108;&#111;&#111;&#120;&#64;&#64;&#65;&#65;&#69;&#88;&#88;&#90;"><font color=#003366>?validateCert@SChannel@gloox@@AAEXXZ</font></a>)<br>tlsschannel.obj : error LNK2019: unresolved external symbol <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#95;&#95;&#105;&#109;&#112;&#95;&#95;&#67;&#101;&#114;&#116;&#78;&#97;&#109;&#101;&#84;&#111;&#83;&#116;&#114;&#65;&#64;&#50;&#48;"><font color=#003366>__imp__CertNameToStrA@20</font></a> referenced in function "private: void __thiscall gloox::SChannel::certData(void)" (<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#63;&#99;&#101;&#114;&#116;&#68;&#97;&#116;&#97;&#64;&#83;&#67;&#104;&#97;&#110;&#110;&#101;&#108;&#64;&#103;&#108;&#111;&#111;&#120;&#64;&#64;&#65;&#65;&#69;&#88;&#88;&#90;"><font color=#003366>?certData@SChannel@gloox@@AAEXXZ</font></a>)<br><br>3. 加入需要的lib, 编译成功<br>ws2_32.lib Dnsapi.lib Secur32.lib Crypt32.lib
<img src ="http://www.cppblog.com/woomsg/aggbug/64200.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/woomsg/" target="_blank">ysong.lee</a> 2008-10-16 20:42 <a href="http://www.cppblog.com/woomsg/archive/2008/10/16/64200.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>