[JDEV] Java Jabber Client
Lyndon Mark Durham
blackjacobin4 at yahoo.com
Tue Nov 7 12:41:12 CST 2000
Greetings fellow Developers,
I am attempting to write a
Jabber client using Java and the Java Xml api from the Java Project X. I
have been testing sending xml to the jabber.org server to get a feel for
the Jabber architecture. Attached is simple socket based program that I
have been using to send xml streams-nonetheless I cant get to register
sucessfully? Are there any other test Jabber servers out there? Any more
ideas- I have tried all the suggestions made so far-and I still get an
<iq type='error' id ='KLMD_86'>.
Is Jabber servers unable to create or register new accounts at present?
Has or is anyone else developed or developing a Java Client? Thanks in
advance for your assistance.
import java.net.*;
import java.io.*;
class JabberSocket {
protected static Socket sk;
protected static PrintWriter outStream;
protected static BufferedReader readIn;
public static void main(String args[]){
try{
sk = new Socket("jabber.org",5222);
outStream = new PrintWriter(sk.getOutputStream(),true);
outStream.println("<?xml version=\"1.0\"
encoding=\"UTF-8\" ?>");
outStream.println("<stream:stream to=\"jabber.org\"
xmlns=\"jabber:client\"
xmlns:stream=\"http://etherx.jabber.org/streams\">");
outStream.println("<iq type=\"set\" id=\"KLMD_86\">");
outStream.println("<query xmlns=\"jabber:iq:auth\">");
outStream.println("<username>stpeter</username>");
outStream.println("<password>dogpound</password>");
outStream.println("<resource>HomePc</resource>");
outStream.println("</query>");
outStream.println("</iq>");
System.out.println("Here");
readIn = new BufferedReader(new
InputStreamReader(sk.getInputStream()));
String data = new String();
while((data = readIn.readLine())!= null)
System.out.println(data);
readIn.close();
outStream.close();
System.out.println("Here");
}catch(IOException ioProb){ioProb.printStackTrace();}
}
}
More information about the JDev
mailing list