This project is read-only.

Below is a simple example of how to use the XMPP library

  • Add a reference to xmpp.dll
  • Add using System.Net.XMPP to your .cs file
  • Create the client, set the credentials, options, event handlers, and connect

XMPPClient XMPPClient = new XMPPClient();

XMPPClient.UserName = "myaccount";
XMPPClient.Password = "password";
XMPPClient.Server = "";
XMPPClient.Domain = "";
XMPPClient.Resource = Guid.NewGuid().ToString();
XMPPClient.Port = 5223;

XMPPClient.UseTLS = true;

XMPPClient.UseOldStyleTLS = true;

XMPPClient.AutoAcceptPresenceSubscribe = false;
XMPPClient.AutomaticallyDownloadAvatars = false;
XMPPClient.RetrieveRoster = false;

XMPPClient.OnStateChanged += new EventHandler(XMPPClient_OnStateChanged);

XMPP States

The state change event is fired whenever something happens to the internal state machine.

As an example:

void XMPPClient_OnStateChanged(object sender, EventArgs e)
    Console.WriteLine("XMPP Client state changed to: {0}", XMPPClient.XMPPState);

    if (XMPPClient.XMPPState == XMPPState.Ready)
        XMPPClient.PresenceStatus.PresenceType = PresenceType.available;
        XMPPClient.PresenceStatus.Status = "online";
        XMPPClient.PresenceStatus.PresenceShow =;


The keys states are:

XMPPState.Unknown   // The client is disconnected

XMPPState.Ready         // The client is connected and ready for operation

XMPP Events

Below is a list of some of the events fired by the XMPP Client:

  • XMPPClient.OnRetrievedRoster  /// The initial roster has been retrieved, use XMPPClient.RosterItems
  • XMPPClient.OnStateChanged  /// The state of the XMPP client has changed
  • XMPPClient.OnNewConversationItem  /// A new chat message has been received
  • XMPPClient.FileTransferManager.OnNewIncomingFileTransferRequest  // A remote user wants to transfer a file.  Use XMPPClient.FileTransferManager.AcceptFileDownload() or DeclineFileDownload()

Common Actions

  • Access the roster
    • XMPPClient.RosterItems
    • RosterItem XMPPClient.FindRosterItem(JID jid)
  • Send a message
    • XMPPClient.SendChatMessage(string strMessage, JID jidto)
    • XMPPClient.SendRawXML(string strXML)
    • XMPPClient.SendXMPP(XMPPMessageBase iq); /// Send an iq or message derived class using base class virtual functions for serialization.
    • XMPPClient.SendObject(object objXMLSerializable) /// Send an iq or message derived class using the XMLSerializer.
  • Change user presence
    • See above state change event handler
  • Develop a custom service
    • See the WPFXMPPClient PrivacyService.cs file for an example
  • ServiceDiscovery
    • XMPPClient.ServerServiceDiscoveryFeatureList  /// Get a list of what has been discovered if AutoQueryServerFeatures is set to true
    • XMPPClient.ServiceDiscoveryLogic.QueryServiceInfo(), ServiceDiscoveryLogic.QueryServiceItems() to force a query

Last edited Feb 29, 2012 at 7:25 AM by bonnbria, version 2


DjangoX Feb 24, 2014 at 2:00 AM 
so the socket server is a DLL in the client all you need to do in include it your resources. and now it works for me. Well sort of.

DjangoX Feb 8, 2014 at 9:10 PM 
I'm having the same issue as ribhuchawla.

jigyanshu Dec 10, 2013 at 7:06 AM 
The name of domain is not working. Do you have any way of initialize to connect and chat.

Estevex Jul 4, 2013 at 11:35 AM 
Can you post the log?

ribhuchawla May 20, 2012 at 7:30 AM 
i am getting socket exception error. anyone there to help ? ? ?