现在我发现我写的IM系统已经完全无法修改成符合XMPP协议了,原因是根据XMPP的定义或者说约定俗成,inbound和outbound的XML stream都是在一个TCP连接中完成的,或者是http的polling。。。而我,为了不在服务器端维护太多的工作线程,采用的是inbound 和 outbound分离的 tcp 连接,这点基于rt_event 并不是象听起来那样困难,要说我之所以有这样好像莫名其妙的想法,还是是受 COM+和 EJB 的影响,大家都说有状态session不好的,占用资源,完事了写到数据库去好了,blablabla 。。。。。于是我就想,嗯,应该每次传完一次tag就关闭好了,线程可宝贵着呐。。。当时我还纳闷那么多客户端服务器要是底层都实现的不一样怎么通信。。事实上维持协议的简单,底层的问题交底层做才是正道啊,线程?多搬几台机器来就好了。。。
4.2. Binding to TCP
Although there is no necessary coupling of an XML stream to a [TCP]
connection (e.g., two entities could connect to each other via
another mechanism such as polling over [HTTP]), this specification
defines a binding of XMPP to TCP only. In the context of
client-to-server communications, a server MUST allow a client to
share a single TCP connection for XML stanzas sent from client to
server and from server to client. In the context of server-to-server
communications, a server MUST use one TCP connection for XML stanzas
sent from the server to the peer and another TCP connection
(initiated by the peer) for stanzas from the peer to the server, for
a total of two TCP connections.