Socket Connection dosnt Respond for Long

I am having some problem with socket connection :

I have created a midlet program with socket connection, which talks to the jabber server on port 5222 with emulator, it's work 100% property. but when I take it to run on som mobile mobile,
I noticed that one line of the code take too much time (inputStream.read) and it just hangs there awaiting for response back. Although it works well with some handsets, I am having these issues with Nokia 6085 and E65.

Please let me know and would really appreciate any help. below is my lines of code, and its the line in RED where I am having problem and where it gets hanged

I am have some problem with socket connection :

I have created a midlet program with socket connection, which talks to the jabber server on port 5222 with emulator, it's work 100% property. but when I take it to run on som mobile mobile,
I noticed that one line of the code take too much time (inputStream.read -> XmlReader ) and it just hangs there awaiting for response back. Although it works well with some handsets, I am having these issues with Nokia 6085 and E65.

Please let me know and would really appreciate any help. below is few lines of my code, and its the line in BOLD where I am having problem and where it gets hanged

StreamConnection connection = (StreamConnection)Connector.open("socket://" + host + ":" + port);
reader = new XmlReader(connection .openInputStream());
writer = new XmlWriter(connection .openOutputStream());

writer.startTag("stream:stream");
writer.attribute("to",host);
writer.attribute("xmlns","jabber:client");
writer.attribute("xmlns:stream","http://etherx.jabber.org/streams");
writer.flush();
// log in
writer.startTag("iq");
writer.attribute("type","set");
writer.attribute("id","auth");
writer.startTag("query");
writer.attribute("xmlns","jabber:iq:auth");

writer.startTag("username");
writer.text(username);
writer.endTag();

writer.startTag("password");
writer.text(password);
writer.endTag();

writer.startTag("resource");
writer.text(resource);
//writer.text(username);
writer.endTag();

writer.endTag(); // query
writer.endTag(); // iq
writer.flush();


reader.next(); // start tag
if(reader.next() == reader.START_TAG) {

String tmp = reader.getName();
}

Syndicate content