Connecting to the Jabber server
Now we’re ready to connect to the Jabber server as a component.
Despite what’s involved (described in Section 9.3.1.1)
it’s very easy to make the connection to the Jabber server using a library such as Jabber::Connection:
my $c = new Jabber::Connection( server => 'localhost:5999', localname => $ID, ns => 'jabber:component:accept', );
We construct a Jabber::Connection
object, specifying the details of the connection we wish to make. The
server argument is used to specify the hostname,
and optionally the port, of the Jabber server to which we wish to connect.
In the case of a component, we must always specify the port (which is
5999 in this example, as shown
in Example 9-8). The same constructor can be used to create a client
connection to the Jabber server, in which case a default port of 5222 (the
standard port for client connections) is assumed if none is
explicitly specified. The localname argument is
used to specify the component’s name, which in this
case is rss.qmacro.dyndns.org. In the same way that
a default port of 5222 is assumed if none is specified, a default
stream namespace of jabber:client is assumed if no
ns argument is specified. Since we want to connect as a
component using the TCP sockets connection method, we must specify the appropriate namespace: jabber:component:accept.
This constructor call results in a stream header being prepared; it looks like the one shown in Example 9-12.
The actual connection attempt, including the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access