Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi,

I am developing a xmpp client application. I need to send ping iq packets to the xmpp server to make sure the server is still alive. How can i send it thru jabber-net library ?
thanks

UPdate: Its not ICMP Ping. Its XEP-0199 http://xmpp.org/extensions/xep-0199.html[^]
Posted
Updated 27-Mar-18 6:09am
v2

it's very important to put the IQTracker.IQ method inside a try/catch because it awaits for a response during the timeout you set, if it doesn't recieve it fires an exception (and that happens very frequently), the most important is to send the IQ, you can use IQHandler to recieve an IQ response .

C#
const int myTimeOut = 500;
//create your IQ to send
jabber.protocol.client.IQ MyIQ = new jabber.protocol.client.IQ(new XmlDocument());

//allows you to send the IQ and wait for the response
IQTracker myIQTracker= new IQTracker(myJabberClient);
            try
            {
                jabber.protocol.client.IQ iq = myIQTracker.IQ(MyIQ, myTimeOut );
            }
            catch(Exception e)
            {
//Put whatever exception you want
            }
            done.Set();
 
Share this answer
 
Pinging is totally unrelated to Jabber (XMPP). It works with the ICMP protocol which normally should be supported by all hosts on a network. Please see:
http://en.wikipedia.org/wiki/Ping_%28networking_utility%29[^],
http://en.wikipedia.org/wiki/Internet_Control_Message_Protocol[^].

You can use the class System.Net.NetworkInformation.Ping:
http://msdn.microsoft.com/en-us/library/system.net.networkinformation.ping%28v=vs.110%29.aspx[^].

—SA
 
Share this answer
 
Comments
Yesudasan Moses 26-May-14 2:19am    
Hi, Its XMPP Ping... XEP-0199 Please check the updated question,..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900