[jdev] Re: jdev Digest, Vol 16, Issue 4
Zhong Li
webjabber at gmail.com
Thu May 5 12:59:56 CDT 2005
You need remove key from selector collection, add itr.remove() after key =
(SelectionKey)itr.next();
On 5/5/05, jdev-request at jabber.org <jdev-request at jabber.org> wrote:
> Send jdev mailing list submissions to
> jdev at jabber.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://mail.jabber.org/mailman/listinfo/jdev
> or, via email, send a message with subject or body 'help' to
> jdev-request at jabber.org
>
> You can reach the person managing the list at
> jdev-owner at jabber.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of jdev digest..."
>
>
> Today's Topics:
>
> 1. Regarding-JSO-Multithreading-Java (Merwin Pinto)
>
>
>
> ---------- Forwarded message ----------
> From: "Merwin Pinto" <pintomerwin at rediffmail.com>
> To: jdev at jabber.org
> Date: 5 May 2005 13:25:49 -0000
> Subject: [jdev] Regarding-JSO-Multithreading-Java
>
>
> 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
> }
> }
>
>
> _______________________________________________
> jdev mailing list
> jdev at jabber.org
> http://mail.jabber.org/mailman/listinfo/jdev
>
>
>
More information about the JDev
mailing list