⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 x1234.htm

📁 Its a xmpp protocol book
💻 HTM
📖 第 1 页 / 共 3 页
字号:
a TCP sockets connection. This means that a component connected in this way
can reside on the same or
a different server to the one running <B
CLASS="COMMAND"
>jabberd</B
>. 
So instead of being loaded directly into the <B
CLASS="COMMAND"
>jabberd</B
>
backbone, TCP sockets-connected components exist and run as separate entities
and can be started and stopped independently.

<A
NAME="JABTDG-CH-4-FOOTNOTE-5"
HREF="#FTN.JABTDG-CH-4-FOOTNOTE-5"
>[6]</A
>&#13;</P
><P
>The configuration syntax for defining a connection point for a component
that is going to connect to the backbone via TCP sockets looks like this:

<A
NAME="AEN1512"
HREF="#FTN.AEN1512"
>[7]</A
>&#13;</P
><P
><PRE
CLASS="SCREEN"
>&#60;accept&#62;
  &#60;ip&#62;127.0.0.1&#60;/ip&#62;
  &#60;port&#62;9001&#60;/port&#62;
  &#60;secret&#62;shhh&#60;/secret&#62;
&#60;/accept&#62;</PRE
></P
><P
>As <TT
CLASS="LITERAL"
>&#60;load/&#62;</TT
> is to
the <I
CLASS="EMPHASIS"
>library load</I
> method, so 
<TT
CLASS="LITERAL"
>&#60;accept/&#62;</TT
> is to
the <I
CLASS="EMPHASIS"
>TCP sockets</I
> method.</P
><P
>The <TT
CLASS="LITERAL"
>&#60;accept/&#62;</TT
> tag usually has three child
tags - 
<TT
CLASS="LITERAL"
>&#60;ip/&#62;</TT
>,
<TT
CLASS="LITERAL"
>&#60;port/&#62;</TT
> and
<TT
CLASS="LITERAL"
>&#60;secret/&#62;</TT
>.

<A
NAME="JABTDG-CH-4-FOOTNOTE-6"
HREF="#FTN.JABTDG-CH-4-FOOTNOTE-6"
>[8]</A
>

Specify an IP address and port to which the component will connect;
if you want the socket to be network interface independent, you can
write <TT
CLASS="LITERAL"
>&#60;ip/&#62;</TT
> (an empty tag)
to listen
on your specified port on all (INADDR_ANY) IP addresses. The 
<TT
CLASS="LITERAL"
>&#60;secret/&#62;</TT
> tag is used in the
handshake when the component connects to the backbone, so that it can
be authenticated. </P
><P
>More information on connecting components with 
<TT
CLASS="LITERAL"
>&#60;accept/&#62;</TT
>
can be found in Part II.</P
><TABLE
CLASS="SIDEBAR"
BORDER="1"
CELLPADDING="5"
><TR
><TD
><DIV
CLASS="SIDEBAR"
><A
NAME="AEN1535"
></A
><P
><B
>XML Streams</B
></P
><P
>Entity to entity connections in the Jabber world pass data to each other using a
technique called <I
CLASS="EMPHASIS"
>XML streams</I
>, which is essentially the
exchange of data
in the form of XML fragments in "streaming" mode over a network connection.</P
><P
>During the lifetime of a connection between two entities,
two complete XML documents will be passed between the entities (if A connects
to B, A will send B a document, fragment by fragment, and B will send A a
document, fragment by fragment). At the start of the connection, the first
things to be exchanged are the document headers&mdash;the outermost (document
root) XML tags. The root tag in each document is 
<TT
CLASS="LITERAL"
>&#60;stream/&#62;</TT
>.</P
><P
>XML namespaces are defined for the content of the XML documents to be
exchanged. 
These namespaces represent what sort of entity connection is taking place. 
In the case of a Jabber client to Jabber server connection, the namespace
is <TT
CLASS="LITERAL"
>jabber:client</TT
>.
In the case of connections based on the TCP sockets connection method,
(using <TT
CLASS="LITERAL"
>&#60;accept/&#62;</TT
>),
the namespace is <TT
CLASS="LITERAL"
>jabber:component:accept</TT
>.</P
><P
>To initiate a connection and conversation, the component will initiate 
the conversation by sending something like this to Jabber:</P
><P
><PRE
CLASS="SCREEN"
>&#60;?xml version="1.0"?&#62;
&#60;stream:stream xmlns:stream="http://etherx.jabber.org/streams"
               xmlns="<TT
CLASS="USERINPUT"
><B
>jabber:component:accept</B
></TT
>"
               to="component.name"&#62;</PRE
></P
><P
>to Jabber.</P
><P
>More detailed information on how XML streams work can be found in
<A
HREF="c3612.htm"
>Chapter 5</A
>.</P
></DIV
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="JABTDG-CH-4-SECT-4.1.3.3"
>STDIO</A
></H3
><P
>The TCP sockets component connect method is used to 
connect an external component to the Jabber backbone via a socket connection
through which streamed XML documents are exchanged. There is
another way for components to connect and exchange XML document streams
with the Jabber backbone&mdash;using the <I
CLASS="EMPHASIS"
>STDIO</I
> connection
method.</P
><P
>While the <I
CLASS="EMPHASIS"
>TCP sockets</I
> method requires external
components to be independently started and stopped, the
<I
CLASS="EMPHASIS"
>STDIO</I
>
method represents a mechanism whereby the <B
CLASS="COMMAND"
>jabberd</B
> process
starts the external component itself. The component to start is specified
inside an <TT
CLASS="LITERAL"
>&#60;exec/&#62;</TT
> tag.
<A
HREF="x1234.htm#JABTDG-CH-4-EX-6"
>Example 4-6</A
>
shows how the <I
CLASS="EMPHASIS"
>STDIO</I
> method is specified
in the configuration.</P
><DIV
CLASS="EXAMPLE"
><A
NAME="JABTDG-CH-4-EX-6"
></A
><P
><B
>Example 4-6. Invoking an external component with <I
CLASS="EMPHASIS"
>STDIO</I
></B
></P
><P
><PRE
CLASS="SCREEN"
>&#60;exec&#62;/path/to/component.py -option a -option b&#60;/exec&#62;</PRE
></P
><P
>Here we see that the component is a Python program and is being passed some
switches at startup.</P
></DIV
><P
>So where's the socket connection in this method? There isn't one. The 
XML documents are exchanged through standard I/O (STDIO). The component
writes XML fragments to STDOUT, and these are received on the Jabber 
backbone. The component receives XML fragments destined for it on STDIN,
fragments which are written out from the Jabber backbone.  </P
><P
>Just as a component connected using the <I
CLASS="EMPHASIS"
>TCP sockets</I
> method
sends an opening document fragment, the component connected with this
<I
CLASS="EMPHASIS"
>STDIO</I
> method sends an opening document fragment to 
initiate a connection and conversation:</P
><P
><PRE
CLASS="SCREEN"
>&#60;?xml version="1.0"?&#62;
&#60;stream:stream xmlns:stream="http://etherx.jabber.org/streams"
               xmlns="<TT
CLASS="USERINPUT"
><B
>jabber:component:exec</B
></TT
>"
               to="component.name"&#62;</PRE
></P
><P
>Notice how the namespace that describes this type of conversation is:</P
><P
><PRE
CLASS="SCREEN"
>jabber:component:exec</PRE
></P
><P
>No secret is required in this case because it is assumed that the component
can be trusted if it is specified in the configuration and execution is
initiated by <B
CLASS="COMMAND"
>jabberd</B
> itself.</P
></DIV
></DIV
></DIV
><H3
CLASS="FOOTNOTES"
>Notes</H3
><TABLE
BORDER="0"
CLASS="FOOTNOTES"
WIDTH="100%"
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="5%"
><A
NAME="FTN.AEN1371"
HREF="x1234.htm#AEN1371"
>[1]</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="95%"
><P
>This identifier is a hexadecimal representation of the user's session id
within the JSM, carried internally as a JID resource in the routing
information.</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="5%"
><A
NAME="FTN.JABTDG-CH-4-FOOTNOTE-1"
HREF="x1234.htm#JABTDG-CH-4-FOOTNOTE-1"
>[2]</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="95%"
><P
>the '15' is the identifier for the socket on 
which the the pertinent client connection has been made</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="5%"
><A
NAME="FTN.JABTDG-CH-4-FOOTNOTE-2"
HREF="x1234.htm#JABTDG-CH-4-FOOTNOTE-2"
>[3]</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="95%"
><P
>Actually, you can also connect to a component running on another Jabber
server - see later in this Chapter.</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="5%"
><A
NAME="FTN.JABTDG-CH-4-FOOTNOTE-3"
HREF="x1234.htm#JABTDG-CH-4-FOOTNOTE-3"
>[4]</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="95%"
><P
>The <I
CLASS="EMPHASIS"
>log</I
> component(s) are actually 
<I
CLASS="EMPHASIS"
>part of</I
> the backbone,
and as such do not need to be 'plugged in' </P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="5%"
><A
NAME="FTN.JABTDG-CH-4-FOOTNOTE-4"
HREF="x1234.htm#JABTDG-CH-4-FOOTNOTE-4"
>[5]</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="95%"
><P
>components receive packets based upon their
type (log, xdb or service), upon a
<TT
CLASS="LITERAL"
>&#60;host/&#62;</TT
>
configuration specification that we'll see later in this chapter, and can also
specify when in the delivery sequence they are to receive the packets</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="5%"
><A
NAME="FTN.JABTDG-CH-4-FOOTNOTE-5"
HREF="x1234.htm#JABTDG-CH-4-FOOTNOTE-5"
>[6]</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="95%"
><P
>It is actually possible to modify the contents of the configuration while
the Jabber server is running, and then send a hangup (HUP) signal to the
processes, which causes a re-read of the configuration and new 
<I
CLASS="EMPHASIS"
>library load</I
>ed components can be started and old ones
can be stopped. There are however currently some problems with this, that
will be addressed in the next round of bug fixes.</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="5%"
><A
NAME="FTN.AEN1512"
HREF="x1234.htm#AEN1512"
>[7]</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="95%"
><P
>The tag name for this TCP sockets configuration stanza is 
<TT
CLASS="LITERAL"
>&#60;accept/&#62;</TT
>, reflecting the low-level socket
library call <TT
CLASS="FUNCTION"
>accept()</TT
> to which it directly relates.</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="5%"
><A
NAME="FTN.JABTDG-CH-4-FOOTNOTE-6"
HREF="x1234.htm#JABTDG-CH-4-FOOTNOTE-6"
>[8]</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="95%"
><P
>There is a fourth tag 
<TT
CLASS="LITERAL"
>&#60;timeout/&#62;</TT
>
with which you can control the heartbeat monitor of this 
component connection, which defaults to a value of 10 if
not explicitly specified (it seldom is).</P
></TD
></TR
></TABLE
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="c1223.htm"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="book1.htm"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="x1581.htm"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Server Architecture and Configuration</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="c1223.htm"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Server Configuration</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -