12-30-2009 04:00 AM
Hi all,
I am trying to connect to a chat server and send messages to known user id. I am able to connect to server and login and send a message to a user. But I am confused about how to listen to incoming messages.
Below is the code which I'm trying.. This code below is written in the run method of a class extending Thread.
final StreamConnection connection = (StreamConnection) Connector
.open("socket://" + this.server + ":" + this.port,Connector.READ_WRITE);
DataOutputStream o = connection.openDataOutputStream();
DataInputStream i = connection.openDataInputStream();
this.writer = new XmlWriter(o);
if(!isLogin){
this.login();
}
this.sendMessage();
int c;
while (true) {
c = i.read();
if (c == -1) {
break;
} else {
System.out.println(String.valueOf(((char) c)));
}
I am trying this in 8330 Simulator. Initially the xml output confirming the authentication is printed but after that i get the exception.
net.rim.device.cldc.io.ippp.SocketBaseIOException: Connection Timed Out
Please can anybody help me understand whats wrong. I want to establish a connection so that instant messaging would be possible between the two users.
Thanks in advance,
baj
Solved! Go to Solution.
01-06-2010 03:42 AM
Any pointers, please?
01-07-2010 07:36 AM
Solved with the help of the below open source project:
12-27-2010 06:02 AM
hi,
I am facing the same problem .
It will be great if u put part of sample code to listen to messages coming from server.
Thanks
12-28-2010 08:34 AM
Hi,
anybody out there ???