[jdev] Regarding-JSO-Multithreading-Java

Merwin Pinto pintomerwin at rediffmail.com
Thu May 5 08:25:49 CDT 2005


  

Hi All,
I had downloaded the JSO some time back. I was trying to run the code .....
now with respect to the example given in ...  example/EchoServer.java. 
i was connecting to the server , Using the  client programme which is also gien in
examples . Now the server works fine for
 most part ...except that some times it goes into a infinite loop....at the 
point where the code tries to remove the session ....for some reason it is
 not able to remove the session and goes into the infinite loop... 
This happens more often when server is running on Linux .... 
Can someone help me with this ...why could this be happening ? .... is the KEY 
not being cancelled ....??? I am not sure
PLEASE HELP ME ..... Solve This Problem
a part of the code is  below...
Thanks a lotregards, Merwin
-------------------------------------------------------
-------------------------------------------------------
conn = JSOImplementation.getInstance().createStream("jabber:client");
src = ChannelStreamSource.createSocket(host, port);

conn.connect(src);
conn.open();
src.register(selector, SelectionKey.OP_READ, conn);

Then ......
Selector.select() to retrieve the available selection keys, 
and process the attached Streams:

while (selector.select() > 0) {
Iterator itr = selector.selectedKeys().iterator();
SelectionKey key;
Stream conn;

while (itr.hasNext()) {
key = (SelectionKey)itr.next();
conn = (Stream)key.attachment();

conn.process();
if (!conn.getCurrentStatus().isConnected())
key.cancel(); //Stream disconnected; remove from selector
}
}





More information about the JDev mailing list