perldoc > Net::XMPP::Client

📖 NAME

đŸ“Ļ Net::XMPP::Client - XMPP Client Module

🚀 Quick Reference

Use CaseCommandDescription
🆕 Create a new client objectNet::XMPP::Client->new(debuglevel=>â€Ļ)Creates the Client object with optional debug settings
🔌 Connect to an XMPP server$Con->Connect(hostname=>â€Ļ, port=>â€Ļ)Opens a TCP connection (or HTTP proxy) to the server
🔄 Run the main event loop$Con->Execute(â€Ļ)High-level loop: connect, auth, process, reconnect
📨 Process incoming packets$Con->Process(timeout)Reads and dispatches packets; returns 1, 0, or undef
🔌 Disconnect from server$Con->Disconnect()Closes the connection
🔗 Check connection status$Con->Connected()Returns 1 if connected, 0 otherwise

📋 SYNOPSIS

đŸ“Ļ Net::XMPP::Client is a module that provides a developer easy access to the Extensible Messaging and Presence Protocol (XMPP).

📝 DESCRIPTION

Client.pm uses Protocol.pm to provide enough high level APIs and automation of the low level APIs that writing an XMPP Client in Perl is trivial. For those that wish to work with the low level you can do that too, but those functions are covered in the documentation for each module.

📌 Net::XMPP::Client provides functions to connect to an XMPP server, login, send and receive messages, set personal information, create a new user account, manage the roster, and disconnect. You can use all or none of the functions, there is no requirement.

For more information on how the details for how Net::XMPP is written please see the help for Net::XMPP itself.

For a full list of high level functions available please see Net::XMPP::Protocol.

🔧 Basic Functions

use Net::XMPP;

$Con = Net::XMPP::Client->new();

$Con->SetCallbacks(...);

$Con->Execute(hostname=>"jabber.org",
              username=>"bob",
              password=>"XXXX",
              resource=>"Work"
             );

For the list of available functions see Net::XMPP::Protocol.

$Con->Disconnect();

âš™ī¸ METHODS

🔧 Basic Functions

new

new(debuglevel=>0|1|2,
    debugfile=>string,
    debugtime=>0|1)

âžĄī¸ Creates the Client object. debugfile should be set to the path for the debug log to be written. If set to "stdout" then the debug will go there. debuglevel controls the amount of debug. For more information about the valid setting for debuglevel, debugfile, and debugtime see Net::XMPP::Debug.

🔌 Connect

Connect(hostname=>string,
        port=>integer,
        timeout=>int,
        connectiontype=>string,
        tls=>0|1,
        srv=>0|1,
        componentname=>string)

âžĄī¸ Opens a connection to the server listed in the hostname (default localhost), on the port (default 5222) listed, using the connectiontype listed (default tcpip). The two connection types available are:

If you specify tls, then TLS will be used if it is available as a feature.

If srv is specified AND Net::DNS is installed and can be loaded, then an SRV query is sent to srv.hostname and the results processed to replace the hostname and port. If the lookup fails, or Net::DNS cannot be loaded, then hostname and port are left alone as the defaults.

Alternatively, you may manually specify componentname as the domain portion of the jid and leave hostname set to the actual hostname of the XMPP server.

⚡ Execute

Execute(hostname=>string,
        port=>int,
        tls=>0|1,
        username=>string,
        password=>string,
        resource=>string,
        register=>0|1,
        connectiontype=>string,
        connecttimeout=>string,
        connectattempts=>int,
        connectsleep=>int,
        processtimeout=>int)

âžĄī¸ Generic inner loop to handle connecting to the server, calling Process, and reconnecting if the connection is lost. There are five callbacks available that are called at various places:

The arguments are passed straight on to the Connect function, except for connectattempts and connectsleep. connectattempts is the number of times that the Component should try to connect before giving up. -1 means try forever. The default is -1. connectsleep is the number of seconds to sleep between each connection attempt.

If you specify register=>1, then the Client will attempt to register the specified account for you, if it does not exist.

🔄 Process

Process(integer)

âžĄī¸ Takes the timeout period as an argument. If no timeout is listed then the function blocks until a packet is received. Otherwise it waits that number of seconds and then exits so your program can continue doing useful things. NOTE: This is important for GUIs. You need to leave time to process GUI commands even if you are waiting for packets. The following are the possible return values, and what they mean:

âš ī¸ IMPORTANT: You need to check the output of every Process. If you get an undef then the connection died and you should behave accordingly.

🔌 Disconnect

Disconnect()

âžĄī¸ Closes the connection to the server.

🔗 Connected

Connected()

âžĄī¸ Returns 1 if the Transport is connected to the server, and 0 if not.

👤 AUTHOR

Originally authored by Ryan Eatmon.

Previously maintained by Eric Hacker.

Currently maintained by Darian Anthony Patrick.

ÂŠī¸ COPYRIGHT

This module is free software, you can redistribute it and/or modify it under the LGPL 2.1.

Net::XMPP::Client
📖 NAME 🚀 Quick Reference 📋 SYNOPSIS 📝 DESCRIPTION
🔧 Basic Functions
âš™ī¸ METHODS
🔧 Basic Functions 🔌 Connect ⚡ Execute 🔄 Process 🔌 Disconnect 🔗 Connected
👤 AUTHOR ÂŠī¸ COPYRIGHT

Generated by phpman v4.9.26-1-g511901d · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-29 15:36 @216.73.217.111
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format

^_top_^