<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Java NIO Server Example</title>
	<atom:link href="http://t-machine.org/index.php/2008/01/22/java-nio-server-example/feed/" rel="self" type="application/rss+xml" />
	<link>http://t-machine.org/index.php/2008/01/22/java-nio-server-example/</link>
	<description>Internet Gaming, Computer Games, Technology, MMO, and Web 2.0</description>
	<lastBuildDate>Sun, 05 Sep 2010 20:30:54 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Karl</title>
		<link>http://t-machine.org/index.php/2008/01/22/java-nio-server-example/comment-page-1/#comment-3005</link>
		<dc:creator>Karl</dc:creator>
		<pubDate>Fri, 03 Jul 2009 13:09:46 +0000</pubDate>
		<guid isPermaLink="false">http://tmachine1.dh.bytemark.co.uk/blog/index.php/2008/01/22/java-nio-server-example/#comment-3005</guid>
		<description>Hello all,
is anybody still using this server?
I noticed there is a FIXME in the ResponseListener.java class. 
Has anybody fixed it? if yes, how?
It says the bug existed on the Server too, so does it mean it&#039;s fixed already on the server side?
thanks a lot.</description>
		<content:encoded><![CDATA[<p>Hello all,<br />
is anybody still using this server?<br />
I noticed there is a FIXME in the ResponseListener.java class.<br />
Has anybody fixed it? if yes, how?<br />
It says the bug existed on the Server too, so does it mean it&#8217;s fixed already on the server side?<br />
thanks a lot.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maurice</title>
		<link>http://t-machine.org/index.php/2008/01/22/java-nio-server-example/comment-page-1/#comment-2858</link>
		<dc:creator>Maurice</dc:creator>
		<pubDate>Sat, 18 Apr 2009 16:51:15 +0000</pubDate>
		<guid isPermaLink="false">http://tmachine1.dh.bytemark.co.uk/blog/index.php/2008/01/22/java-nio-server-example/#comment-2858</guid>
		<description>Hi. I am trying to create a client-server application for windows, that does the following:

From the client side (extending StringBasedClient):

- Install a windows hook and detect application window activations by  capturing window focus events.

-  On window focus detection, get the window title and process id, and send them to the server.

From the server side (extending StringBasedServer):

- Listen for window focus events, sent by one or more clients.

- show the window text and the application process id from those events in a gui

I&#039;m creating strings to perform communication between the clients and the server, concatenating first the PID with a &#039;\n&#039;, and later the window text, just when the user activates an app.

I&#039;m interested in creating a JList that handles the current connected clients. I&#039;ve done it holding a SelectionKey that the user selects with the valueChanged event on the JList, to filter what messages are seen on the gui, using this code for the server:

public void processStringMessage(SelectionKey key, String message)
{
    if(key.equals(usrSelectedKey)
    {
        //take the message, parse it and put the contents on the gui
    }
}

Unfortunately, the code does work well, and I&#039;m not sure what is the cause. Maybe I have missing a synchronized block, or maybe is something that I haven´t seen on the documentation.

Thank you.</description>
		<content:encoded><![CDATA[<p>Hi. I am trying to create a client-server application for windows, that does the following:</p>
<p>From the client side (extending StringBasedClient):</p>
<p>- Install a windows hook and detect application window activations by  capturing window focus events.</p>
<p>-  On window focus detection, get the window title and process id, and send them to the server.</p>
<p>From the server side (extending StringBasedServer):</p>
<p>- Listen for window focus events, sent by one or more clients.</p>
<p>- show the window text and the application process id from those events in a gui</p>
<p>I&#8217;m creating strings to perform communication between the clients and the server, concatenating first the PID with a &#8216;\n&#8217;, and later the window text, just when the user activates an app.</p>
<p>I&#8217;m interested in creating a JList that handles the current connected clients. I&#8217;ve done it holding a SelectionKey that the user selects with the valueChanged event on the JList, to filter what messages are seen on the gui, using this code for the server:</p>
<p>public void processStringMessage(SelectionKey key, String message)<br />
{<br />
    if(key.equals(usrSelectedKey)<br />
    {<br />
        //take the message, parse it and put the contents on the gui<br />
    }<br />
}</p>
<p>Unfortunately, the code does work well, and I&#8217;m not sure what is the cause. Maybe I have missing a synchronized block, or maybe is something that I haven´t seen on the documentation.</p>
<p>Thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rwan</title>
		<link>http://t-machine.org/index.php/2008/01/22/java-nio-server-example/comment-page-1/#comment-2349</link>
		<dc:creator>Rwan</dc:creator>
		<pubDate>Tue, 16 Dec 2008 13:36:17 +0000</pubDate>
		<guid isPermaLink="false">http://tmachine1.dh.bytemark.co.uk/blog/index.php/2008/01/22/java-nio-server-example/#comment-2349</guid>
		<description>Hi Adam,

I &#039;am in the process of researching comet in general. I just wanted to prototype comet for one of my application where I am currently polling the server ( especially a queue) to download the messages if any.It would be gr8 if you could provide some hands on for this.

Thanks</description>
		<content:encoded><![CDATA[<p>Hi Adam,</p>
<p>I &#8216;am in the process of researching comet in general. I just wanted to prototype comet for one of my application where I am currently polling the server ( especially a queue) to download the messages if any.It would be gr8 if you could provide some hands on for this.</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: T=Machine &#187; Project moved: java NIO servers</title>
		<link>http://t-machine.org/index.php/2008/01/22/java-nio-server-example/comment-page-1/#comment-2229</link>
		<dc:creator>T=Machine &#187; Project moved: java NIO servers</dc:creator>
		<pubDate>Mon, 24 Nov 2008 16:06:50 +0000</pubDate>
		<guid isPermaLink="false">http://tmachine1.dh.bytemark.co.uk/blog/index.php/2008/01/22/java-nio-server-example/#comment-2229</guid>
		<description>[...] For those of you who wanted the source recently, there&#8217;s links to the downoad page from the SF page - the three files marked &#8220;version 1.0.0&#8243; are *precisely* the same ones I originally uploaded to the blog post. [...]</description>
		<content:encoded><![CDATA[<p>[...] For those of you who wanted the source recently, there&#8217;s links to the downoad page from the SF page &#8211; the three files marked &#8220;version 1.0.0&#8243; are *precisely* the same ones I originally uploaded to the blog post. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://t-machine.org/index.php/2008/01/22/java-nio-server-example/comment-page-1/#comment-1866</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Mon, 07 Jul 2008 14:10:47 +0000</pubDate>
		<guid isPermaLink="false">http://tmachine1.dh.bytemark.co.uk/blog/index.php/2008/01/22/java-nio-server-example/#comment-1866</guid>
		<description>Thanks Diego, I&#039;ll give it a try.

If I&#039;m reading the source right, there&#039;s just a single thread handling the IO stuff - so everything is synchronized already? For example, If I have clients connecting, sending messages, and clients dropping their connection all at the same time, in the server class I&#039;ll see everything serialized, something like:

processStringMessage();
processStringMessage();
keyCancelled();
processStringMessage();
keyCancelled();
processStringMessage();
etc...

I ask because I&#039;m making a small player manager class which keeps a hash map of all connected clients etc. I guess I don&#039;t need to synchronize anything in it because all these notifications are coming in serialized, as far as I can tell.

Thanks</description>
		<content:encoded><![CDATA[<p>Thanks Diego, I&#8217;ll give it a try.</p>
<p>If I&#8217;m reading the source right, there&#8217;s just a single thread handling the IO stuff &#8211; so everything is synchronized already? For example, If I have clients connecting, sending messages, and clients dropping their connection all at the same time, in the server class I&#8217;ll see everything serialized, something like:</p>
<p>processStringMessage();<br />
processStringMessage();<br />
keyCancelled();<br />
processStringMessage();<br />
keyCancelled();<br />
processStringMessage();<br />
etc&#8230;</p>
<p>I ask because I&#8217;m making a small player manager class which keeps a hash map of all connected clients etc. I guess I don&#8217;t need to synchronize anything in it because all these notifications are coming in serialized, as far as I can tell.</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Diego Cassinera</title>
		<link>http://t-machine.org/index.php/2008/01/22/java-nio-server-example/comment-page-1/#comment-1823</link>
		<dc:creator>Diego Cassinera</dc:creator>
		<pubDate>Fri, 06 Jun 2008 13:28:33 +0000</pubDate>
		<guid isPermaLink="false">http://tmachine1.dh.bytemark.co.uk/blog/index.php/2008/01/22/java-nio-server-example/#comment-1823</guid>
		<description>In regards to closing a connection,  its very simple.  In your implementation of processStringMessage throw a closedChannelException, this in turn will do the cleanup of the socket.</description>
		<content:encoded><![CDATA[<p>In regards to closing a connection,  its very simple.  In your implementation of processStringMessage throw a closedChannelException, this in turn will do the cleanup of the socket.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Diego Cassinera</title>
		<link>http://t-machine.org/index.php/2008/01/22/java-nio-server-example/comment-page-1/#comment-1822</link>
		<dc:creator>Diego Cassinera</dc:creator>
		<pubDate>Fri, 06 Jun 2008 13:05:45 +0000</pubDate>
		<guid isPermaLink="false">http://tmachine1.dh.bytemark.co.uk/blog/index.php/2008/01/22/java-nio-server-example/#comment-1822</guid>
		<description>This statement is incorrect
This is done to really test if the socket its really open.
This is not done to test, is done to force an error if the connection is stale</description>
		<content:encoded><![CDATA[<p>This statement is incorrect<br />
This is done to really test if the socket its really open.<br />
This is not done to test, is done to force an error if the connection is stale</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Diego Cassinera</title>
		<link>http://t-machine.org/index.php/2008/01/22/java-nio-server-example/comment-page-1/#comment-1821</link>
		<dc:creator>Diego Cassinera</dc:creator>
		<pubDate>Fri, 06 Jun 2008 13:03:12 +0000</pubDate>
		<guid isPermaLink="false">http://tmachine1.dh.bytemark.co.uk/blog/index.php/2008/01/22/java-nio-server-example/#comment-1821</guid>
		<description>One more comment in regards to the change i mentioned yesterday.
The new run function does not need to cleanup ssc, since its cleanned in runex by the finally block.
Another change I implemented is a NOOP message in my protocol.  When the selector does not return any keys for 60 I send an NOOP to all connected channels.  This is done to really test if the socket its really open.</description>
		<content:encoded><![CDATA[<p>One more comment in regards to the change i mentioned yesterday.<br />
The new run function does not need to cleanup ssc, since its cleanned in runex by the finally block.<br />
Another change I implemented is a NOOP message in my protocol.  When the selector does not return any keys for 60 I send an NOOP to all connected channels.  This is done to really test if the socket its really open.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Diego Cassinera</title>
		<link>http://t-machine.org/index.php/2008/01/22/java-nio-server-example/comment-page-1/#comment-1819</link>
		<dc:creator>Diego Cassinera</dc:creator>
		<pubDate>Thu, 05 Jun 2008 16:27:58 +0000</pubDate>
		<guid isPermaLink="false">http://tmachine1.dh.bytemark.co.uk/blog/index.php/2008/01/22/java-nio-server-example/#comment-1819</guid>
		<description>I just wanted to let everybody know that I&#039;m running into an issue where the selector stops responding after running for 6 hours.  I verified that the thread still running, however, selectedKeys() stops returning any keys.  This is most probable a VM bug,  I&#039;m running 1.6.0.2 from sun on linux suse linux.

To work around the issue I added code to recreate the selector after 60 seconds of inactivity and no connected clients.
The code of the change I made follows:

Renamed the run function to runEx.
In the runEx function after while( iterator.hasNext() ) added 
lastMessage = System.currentTimeMillis();

After lastPostProcessBegan = currentPostProcessBegan; added the following code to break out of the function if no messages were received in the las 60 seconds and I have no open connections.
 
        if (currentPostProcessBegan - lastMessage &gt; 60000  &amp;&amp;
            connectedChannels.isEmpty())
        {
          System.out.println (Thread.currentThread().getName()+&quot;::runEx &quot;+
                              &quot;No messages in the last 60 secs (rerun)&quot;);
          return;
        }

created a new run function that calls runEx  the function looks like this

  public void run ()
  {
    while (status != STOPPING)
    {
      lastMessage = System.currentTimeMillis();
      status = STARTED;
      runEx();
      if (listener)
      {
        try
        {
          ssc.close();
        }
        catch (Exception e)
        {
          e.printStackTrace();
        }
        ssc = null;          
      }
    }
  }


Note that the member variable listener is something I added to the code to support multiple threads working in parallel to support 1000&#039;s of users where only one of the threads acts as a listener.</description>
		<content:encoded><![CDATA[<p>I just wanted to let everybody know that I&#8217;m running into an issue where the selector stops responding after running for 6 hours.  I verified that the thread still running, however, selectedKeys() stops returning any keys.  This is most probable a VM bug,  I&#8217;m running 1.6.0.2 from sun on linux suse linux.</p>
<p>To work around the issue I added code to recreate the selector after 60 seconds of inactivity and no connected clients.<br />
The code of the change I made follows:</p>
<p>Renamed the run function to runEx.<br />
In the runEx function after while( iterator.hasNext() ) added<br />
lastMessage = System.currentTimeMillis();</p>
<p>After lastPostProcessBegan = currentPostProcessBegan; added the following code to break out of the function if no messages were received in the las 60 seconds and I have no open connections.</p>
<p>        if (currentPostProcessBegan &#8211; lastMessage &gt; 60000  &amp;&amp;<br />
            connectedChannels.isEmpty())<br />
        {<br />
          System.out.println (Thread.currentThread().getName()+&#8221;::runEx &#8220;+<br />
                              &#8220;No messages in the last 60 secs (rerun)&#8221;);<br />
          return;<br />
        }</p>
<p>created a new run function that calls runEx  the function looks like this</p>
<p>  public void run ()<br />
  {<br />
    while (status != STOPPING)<br />
    {<br />
      lastMessage = System.currentTimeMillis();<br />
      status = STARTED;<br />
      runEx();<br />
      if (listener)<br />
      {<br />
        try<br />
        {<br />
          ssc.close();<br />
        }<br />
        catch (Exception e)<br />
        {<br />
          e.printStackTrace();<br />
        }<br />
        ssc = null;<br />
      }<br />
    }<br />
  }</p>
<p>Note that the member variable listener is something I added to the code to support multiple threads working in parallel to support 1000&#8242;s of users where only one of the threads acts as a listener.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: adam</title>
		<link>http://t-machine.org/index.php/2008/01/22/java-nio-server-example/comment-page-1/#comment-1785</link>
		<dc:creator>adam</dc:creator>
		<pubDate>Thu, 22 May 2008 20:30:16 +0000</pubDate>
		<guid isPermaLink="false">http://tmachine1.dh.bytemark.co.uk/blog/index.php/2008/01/22/java-nio-server-example/#comment-1785</guid>
		<description>EDIT: This project now has its own page for all info related to it - &lt;a href=&quot;http://t-machine.org/index.php/category/projects/nio-server/&quot; rel=&quot;nofollow&quot;&gt;http://t-machine.org/index.php/category/projects/nio-server/&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>EDIT: This project now has its own page for all info related to it &#8211; <a href="http://t-machine.org/index.php/category/projects/nio-server/"  rel="nofollow">http://t-machine.org/index.php/category/projects/nio-server/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://t-machine.org/index.php/2008/01/22/java-nio-server-example/comment-page-1/#comment-1784</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Thu, 22 May 2008 12:44:03 +0000</pubDate>
		<guid isPermaLink="false">http://tmachine1.dh.bytemark.co.uk/blog/index.php/2008/01/22/java-nio-server-example/#comment-1784</guid>
		<description>Hi Adam,

I opted to let the client connect, but then I send them a &#039;please disconnect&#039; command. My client sidegets the message then politely closes the connection from its side. That seems to work great. The only thing I&#039;m worried about is - the server right now can&#039;t hard kick a user if it wants to, it needs to ask the client to do it! I&#039;ll give your recommendation a try though, it sounds like another correct way of doing it.

The code you posted is great by the way, I was previously using a classic threaded server model, this architecture is much easier to work with in my opinion,

Thanks!</description>
		<content:encoded><![CDATA[<p>Hi Adam,</p>
<p>I opted to let the client connect, but then I send them a &#8216;please disconnect&#8217; command. My client sidegets the message then politely closes the connection from its side. That seems to work great. The only thing I&#8217;m worried about is &#8211; the server right now can&#8217;t hard kick a user if it wants to, it needs to ask the client to do it! I&#8217;ll give your recommendation a try though, it sounds like another correct way of doing it.</p>
<p>The code you posted is great by the way, I was previously using a classic threaded server model, this architecture is much easier to work with in my opinion,</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: adam</title>
		<link>http://t-machine.org/index.php/2008/01/22/java-nio-server-example/comment-page-1/#comment-1780</link>
		<dc:creator>adam</dc:creator>
		<pubDate>Wed, 21 May 2008 11:17:57 +0000</pubDate>
		<guid isPermaLink="false">http://tmachine1.dh.bytemark.co.uk/blog/index.php/2008/01/22/java-nio-server-example/#comment-1780</guid>
		<description>Diego - feel free to write as much as you want. I&#039;m just glad it&#039;s useful to you :).</description>
		<content:encoded><![CDATA[<p>Diego &#8211; feel free to write as much as you want. I&#8217;m just glad it&#8217;s useful to you :).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: adam</title>
		<link>http://t-machine.org/index.php/2008/01/22/java-nio-server-example/comment-page-1/#comment-1779</link>
		<dc:creator>adam</dc:creator>
		<pubDate>Wed, 21 May 2008 11:16:19 +0000</pubDate>
		<guid isPermaLink="false">http://tmachine1.dh.bytemark.co.uk/blog/index.php/2008/01/22/java-nio-server-example/#comment-1779</guid>
		<description>Have you tried accepting the channel, THEN closing it?

I would suggest at least that you should accept it, and then add it to a queue of channels to reject as soon as they become writeable.

Then you can at least output e.g. a message &quot;Too many connections; try again later&quot;.

This will make your debugging much easier when you find at some unexpected time in the future one of your clients can&#039;t connect for no apparent reason (i.e. you&#039;ve got another client somewhere that&#039;s still connected that you forgot about ;))</description>
		<content:encoded><![CDATA[<p>Have you tried accepting the channel, THEN closing it?</p>
<p>I would suggest at least that you should accept it, and then add it to a queue of channels to reject as soon as they become writeable.</p>
<p>Then you can at least output e.g. a message &#8220;Too many connections; try again later&#8221;.</p>
<p>This will make your debugging much easier when you find at some unexpected time in the future one of your clients can&#8217;t connect for no apparent reason (i.e. you&#8217;ve got another client somewhere that&#8217;s still connected that you forgot about ;))</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://t-machine.org/index.php/2008/01/22/java-nio-server-example/comment-page-1/#comment-1777</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Wed, 21 May 2008 04:06:56 +0000</pubDate>
		<guid isPermaLink="false">http://tmachine1.dh.bytemark.co.uk/blog/index.php/2008/01/22/java-nio-server-example/#comment-1777</guid>
		<description>Hi,

How can we reject a connection? Let&#039;s say I only want to support 5 users. I added a piece of code like this:

if( key.isAcceptable() )
    System.out.println(&quot;Client wants to connect.........&quot;);
    if (getShouldAllowNewConnection(key)) {
        key.channel().close();
        continue;
    }
    // Normal stuff for adding the new key to &quot;connectedChannels&quot;.

That works, but then that same client can never attempt to reconnect again. It seems like the client will keep using the same socket channel somehow which the server has permanently condemned because of the channel().close() call. What&#039;s the right way reject the client, but still let them attempt to connect thereafter?

Thanks,
Mark</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>How can we reject a connection? Let&#8217;s say I only want to support 5 users. I added a piece of code like this:</p>
<p>if( key.isAcceptable() )<br />
    System.out.println(&#8220;Client wants to connect&#8230;&#8230;&#8230;&#8221;);<br />
    if (getShouldAllowNewConnection(key)) {<br />
        key.channel().close();<br />
        continue;<br />
    }<br />
    // Normal stuff for adding the new key to &#8220;connectedChannels&#8221;.</p>
<p>That works, but then that same client can never attempt to reconnect again. It seems like the client will keep using the same socket channel somehow which the server has permanently condemned because of the channel().close() call. What&#8217;s the right way reject the client, but still let them attempt to connect thereafter?</p>
<p>Thanks,<br />
Mark</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Diego Cassinera</title>
		<link>http://t-machine.org/index.php/2008/01/22/java-nio-server-example/comment-page-1/#comment-1759</link>
		<dc:creator>Diego Cassinera</dc:creator>
		<pubDate>Wed, 14 May 2008 16:53:43 +0000</pubDate>
		<guid isPermaLink="false">http://tmachine1.dh.bytemark.co.uk/blog/index.php/2008/01/22/java-nio-server-example/#comment-1759</guid>
		<description>Sandy,

	I&#039;m not quite sure if this is the place to discuss a specific implementation of a chat server using this code, so I just will give you a gist.  

1)Created a class that extends the StringBasedServer class.
In the overloaded processStringMessage member function I enqueue the received message along with its SelectionKey into a LinkedBlockingQueue.
2)Created a class called MessagePump that implements Runnable and dequeues messages from the  LinkedBlockingQueue.  This class implements most of the chat server protocol that I&#039;m using.  For example when a message its dequeued from the queue and the SelectionKey has never been seen by this class, a session object its created.  In the session object I store the SelectionKey, and all other chat protocol information.  The session object is stored in a Hashtable that uses the SelectionKey as its key.

3)To support 1000&#039;s of users I did some modifications to  Adam&#039;s code.  The key modifications that I did is to be able to extend StringBasedServer in a non listening mode. I did this mainly so I can have multiple threads that extend StringBasedServer each one processing all IO for a subset of the open connections. For my server the order at which messages are sent and received is not important, so I have multiple instances of  StringBasedServer and MessagePump.  Overall its more important to have multiple instances of message pump since one incoming message can become 1000 of outgoing messages.  Also since the message pump implements the protocol its a bit more cpu intense than the network worker thread.


Since this is Adam&#039;s page I&#039;m not quite sure if he is interested on the details of a full blown description of my implementation.  Theres are a few other modifications that I did, but this is just a gist of what I had to do.  If you need to contact me directly, I can be reached at www.uiija.com, use the contact us link at the bottom of the page.</description>
		<content:encoded><![CDATA[<p>Sandy,</p>
<p>	I&#8217;m not quite sure if this is the place to discuss a specific implementation of a chat server using this code, so I just will give you a gist.  </p>
<p>1)Created a class that extends the StringBasedServer class.<br />
In the overloaded processStringMessage member function I enqueue the received message along with its SelectionKey into a LinkedBlockingQueue.<br />
2)Created a class called MessagePump that implements Runnable and dequeues messages from the  LinkedBlockingQueue.  This class implements most of the chat server protocol that I&#8217;m using.  For example when a message its dequeued from the queue and the SelectionKey has never been seen by this class, a session object its created.  In the session object I store the SelectionKey, and all other chat protocol information.  The session object is stored in a Hashtable that uses the SelectionKey as its key.</p>
<p>3)To support 1000&#8242;s of users I did some modifications to  Adam&#8217;s code.  The key modifications that I did is to be able to extend StringBasedServer in a non listening mode. I did this mainly so I can have multiple threads that extend StringBasedServer each one processing all IO for a subset of the open connections. For my server the order at which messages are sent and received is not important, so I have multiple instances of  StringBasedServer and MessagePump.  Overall its more important to have multiple instances of message pump since one incoming message can become 1000 of outgoing messages.  Also since the message pump implements the protocol its a bit more cpu intense than the network worker thread.</p>
<p>Since this is Adam&#8217;s page I&#8217;m not quite sure if he is interested on the details of a full blown description of my implementation.  Theres are a few other modifications that I did, but this is just a gist of what I had to do.  If you need to contact me directly, I can be reached at <a href="http://www.uiija.com" onclick="javascript:pageTracker._trackPageview('/outbound/comment/http://www.uiija.com');" rel="nofollow">http://www.uiija.com</a>, use the contact us link at the bottom of the page.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://t-machine.org/index.php/2008/01/22/java-nio-server-example/comment-page-1/#comment-1758</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Tue, 13 May 2008 16:17:12 +0000</pubDate>
		<guid isPermaLink="false">http://tmachine1.dh.bytemark.co.uk/blog/index.php/2008/01/22/java-nio-server-example/#comment-1758</guid>
		<description>Adam,

Thanks for this sample code, it&#039;s great. I just wonder about how the client connection is supposed to get notified that the server has sent it a message.  It seems that in StringBasedClient, there is a member:

    iMessageProcessor messageProcessor

It&#039;s not set anywhere, so I just added a parameter to connect(), so that it takes a reference to an iMessageProcessor object. Once set, it seems to work fine with the string client calling receiveMessage()  everytime the server pushes a message to the client. This is how it&#039;s supposed to work, right?

Thanks,
Mark</description>
		<content:encoded><![CDATA[<p>Adam,</p>
<p>Thanks for this sample code, it&#8217;s great. I just wonder about how the client connection is supposed to get notified that the server has sent it a message.  It seems that in StringBasedClient, there is a member:</p>
<p>    iMessageProcessor messageProcessor</p>
<p>It&#8217;s not set anywhere, so I just added a parameter to connect(), so that it takes a reference to an iMessageProcessor object. Once set, it seems to work fine with the string client calling receiveMessage()  everytime the server pushes a message to the client. This is how it&#8217;s supposed to work, right?</p>
<p>Thanks,<br />
Mark</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sandy</title>
		<link>http://t-machine.org/index.php/2008/01/22/java-nio-server-example/comment-page-1/#comment-1756</link>
		<dc:creator>sandy</dc:creator>
		<pubDate>Sun, 11 May 2008 07:36:45 +0000</pubDate>
		<guid isPermaLink="false">http://tmachine1.dh.bytemark.co.uk/blog/index.php/2008/01/22/java-nio-server-example/#comment-1756</guid>
		<description>Hi Diego,

I need to write a chat and a voice chat server, which should support around 1000 users, Could you please guide me in this?

~Sandy</description>
		<content:encoded><![CDATA[<p>Hi Diego,</p>
<p>I need to write a chat and a voice chat server, which should support around 1000 users, Could you please guide me in this?</p>
<p>~Sandy</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Diego Cassinera</title>
		<link>http://t-machine.org/index.php/2008/01/22/java-nio-server-example/comment-page-1/#comment-1755</link>
		<dc:creator>Diego Cassinera</dc:creator>
		<pubDate>Thu, 08 May 2008 14:15:33 +0000</pubDate>
		<guid isPermaLink="false">http://tmachine1.dh.bytemark.co.uk/blog/index.php/2008/01/22/java-nio-server-example/#comment-1755</guid>
		<description>Hello again.  I have a little heads up.
I wrote a nice chat server using the code.  It worked fine on windows using the sun vm.  However when I moved the code to my suse Linux server the server gets stuck when sending data to a channel that does not have incoming data.  Suse Linux by default installs IBM j9 vm.  To fix the problem I installed the Sun vm and now everything works fine.

Diego</description>
		<content:encoded><![CDATA[<p>Hello again.  I have a little heads up.<br />
I wrote a nice chat server using the code.  It worked fine on windows using the sun vm.  However when I moved the code to my suse Linux server the server gets stuck when sending data to a channel that does not have incoming data.  Suse Linux by default installs IBM j9 vm.  To fix the problem I installed the Sun vm and now everything works fine.</p>
<p>Diego</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Diego Cassinera</title>
		<link>http://t-machine.org/index.php/2008/01/22/java-nio-server-example/comment-page-1/#comment-1750</link>
		<dc:creator>Diego Cassinera</dc:creator>
		<pubDate>Fri, 02 May 2008 21:19:03 +0000</pubDate>
		<guid isPermaLink="false">http://tmachine1.dh.bytemark.co.uk/blog/index.php/2008/01/22/java-nio-server-example/#comment-1750</guid>
		<description>Thanks.


In regards to the spinning bug that I mentioned before.  The simple fix is to add the following code to readIncomingMessageFromKey 
            if (bytesRead == -1)
            {
              throw new IOException(&quot;Channel Closed&quot;);
            }
after 
            if( bufferIsEmpty )
            {
              bytesRead = ((ReadableByteChannel) key.channel()).read( bb );
            }


Another question
In StringBasedServer.run after

              Set keys = selector.selectedKeys();
              Iterator iterator = keys.iterator();
              while( iterator.hasNext() )</description>
		<content:encoded><![CDATA[<p>Thanks.</p>
<p>In regards to the spinning bug that I mentioned before.  The simple fix is to add the following code to readIncomingMessageFromKey<br />
            if (bytesRead == -1)<br />
            {<br />
              throw new IOException(&#8220;Channel Closed&#8221;);<br />
            }<br />
after<br />
            if( bufferIsEmpty )<br />
            {<br />
              bytesRead = ((ReadableByteChannel) key.channel()).read( bb );<br />
            }</p>
<p>Another question<br />
In StringBasedServer.run after</p>
<p>              Set keys = selector.selectedKeys();<br />
              Iterator iterator = keys.iterator();<br />
              while( iterator.hasNext() )</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: adam</title>
		<link>http://t-machine.org/index.php/2008/01/22/java-nio-server-example/comment-page-1/#comment-1746</link>
		<dc:creator>adam</dc:creator>
		<pubDate>Thu, 01 May 2008 01:55:24 +0000</pubDate>
		<guid isPermaLink="false">http://tmachine1.dh.bytemark.co.uk/blog/index.php/2008/01/22/java-nio-server-example/#comment-1746</guid>
		<description>If you read through the docs I wrote for this, you&#039;ll find somewhere something that says &quot;NEVER USE ATTACHMENT() - IT DOESNT WORK&quot; (although in more words than that :)).

Yes, attachment() is broken.

Yes, Sun has known about this for at least 4 years (I logged a bug on it with them).

No, as far as I know, they haven&#039;t fixed it yet.

Yes, this is pretty depressing :).

Oh, and - if you read any of the books published on NIO, they probably won&#039;t mention this. Because most of the authors never actually tried using NIO on any real project. Sigh.</description>
		<content:encoded><![CDATA[<p>If you read through the docs I wrote for this, you&#8217;ll find somewhere something that says &#8220;NEVER USE ATTACHMENT() &#8211; IT DOESNT WORK&#8221; (although in more words than that :)).</p>
<p>Yes, attachment() is broken.</p>
<p>Yes, Sun has known about this for at least 4 years (I logged a bug on it with them).</p>
<p>No, as far as I know, they haven&#8217;t fixed it yet.</p>
<p>Yes, this is pretty depressing :).</p>
<p>Oh, and &#8211; if you read any of the books published on NIO, they probably won&#8217;t mention this. Because most of the authors never actually tried using NIO on any real project. Sigh.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Diego Cassinera</title>
		<link>http://t-machine.org/index.php/2008/01/22/java-nio-server-example/comment-page-1/#comment-1745</link>
		<dc:creator>Diego Cassinera</dc:creator>
		<pubDate>Thu, 01 May 2008 00:53:57 +0000</pubDate>
		<guid isPermaLink="false">http://tmachine1.dh.bytemark.co.uk/blog/index.php/2008/01/22/java-nio-server-example/#comment-1745</guid>
		<description>Adam,  I&#039;m running into another issue, and again I don&#039;t think its your code.
During ProcessStringMessage I&#039;m attaching my session object to the key.  On following calls to ProcessStringMessage for the same client, the attachment is gone.  
I read the documentation and it does not say anything about when or for how long the attachment will be there so I&#039;m going with the assumption that is for the life of the key.  

I know that its being set because I can retrieve it with a call attachment() after I have set it.  Originally I was doing the attachment from a different thread, but I have changed my code so its done in ProcessStringMessage.  

I also looked into your code and you are not using the attachment, so the only conclusion I have is that java lost it.
The attachment its not crucial since I can store my session object in a hashtable, however it would be nice to get to my session without the need of a lookup.

Also  I have run the code under the debugger with a watch on the attachment,  the watch does not trigger, but attachment still returns null.

Thank You
Again Diego</description>
		<content:encoded><![CDATA[<p>Adam,  I&#8217;m running into another issue, and again I don&#8217;t think its your code.<br />
During ProcessStringMessage I&#8217;m attaching my session object to the key.  On following calls to ProcessStringMessage for the same client, the attachment is gone.<br />
I read the documentation and it does not say anything about when or for how long the attachment will be there so I&#8217;m going with the assumption that is for the life of the key.  </p>
<p>I know that its being set because I can retrieve it with a call attachment() after I have set it.  Originally I was doing the attachment from a different thread, but I have changed my code so its done in ProcessStringMessage.  </p>
<p>I also looked into your code and you are not using the attachment, so the only conclusion I have is that java lost it.<br />
The attachment its not crucial since I can store my session object in a hashtable, however it would be nice to get to my session without the need of a lookup.</p>
<p>Also  I have run the code under the debugger with a watch on the attachment,  the watch does not trigger, but attachment still returns null.</p>
<p>Thank You<br />
Again Diego</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: adam</title>
		<link>http://t-machine.org/index.php/2008/01/22/java-nio-server-example/comment-page-1/#comment-1744</link>
		<dc:creator>adam</dc:creator>
		<pubDate>Wed, 30 Apr 2008 15:15:32 +0000</pubDate>
		<guid isPermaLink="false">http://tmachine1.dh.bytemark.co.uk/blog/index.php/2008/01/22/java-nio-server-example/#comment-1744</guid>
		<description>Thanks, well spotted :).

Re: 64 sockets - that&#039;s the default limit that Windows puts on IOCP (completion ports), although you can programmatically tell windows to change the limit to something higher.

From memory, there WAS a bug in Java 1.4.0 (about 4 years ago) where the Sun programmers had forgotten to increase this limit, but it&#039;s been fixed for many years now. I suspect that what you read was a rumour from a half-remembered description of that bug?</description>
		<content:encoded><![CDATA[<p>Thanks, well spotted :).</p>
<p>Re: 64 sockets &#8211; that&#8217;s the default limit that Windows puts on IOCP (completion ports), although you can programmatically tell windows to change the limit to something higher.</p>
<p>From memory, there WAS a bug in Java 1.4.0 (about 4 years ago) where the Sun programmers had forgotten to increase this limit, but it&#8217;s been fixed for many years now. I suspect that what you read was a rumour from a half-remembered description of that bug?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Diego Cassinera</title>
		<link>http://t-machine.org/index.php/2008/01/22/java-nio-server-example/comment-page-1/#comment-1743</link>
		<dc:creator>Diego Cassinera</dc:creator>
		<pubDate>Wed, 30 Apr 2008 13:13:21 +0000</pubDate>
		<guid isPermaLink="false">http://tmachine1.dh.bytemark.co.uk/blog/index.php/2008/01/22/java-nio-server-example/#comment-1743</guid>
		<description>First of all, I want to thank you for the work you put into this.  It looks quite nice.  Also wanted to tell you that I found a bug in the code.  If a client sends to the server a partial message the server spins trying to read the message even do the client has disconnected.  It does not look like a bug in your code, it may be an issue in windows.  However this is what I did to reproduce.  I connected to the server using telnet and typed the following &quot;1234567890&quot;, the server read the first 4 bytes set it self to wait for a large message.  On the telnet side, I pressed ctrl+] and quited out of telnet.  The server stayed in a loop trying to read from client.

I read somewhere that selectors can only handle 64 sockets,  I can&#039;t recall were I read this and as you said the doc on nio is spotty at best.  If it is so, what would you think is the best approach on your code to handle this.  1) create a thread for each selector or to process all the selectors using the same thread iterating threw the selectors ?

Thank You Again
Diego Cassinera</description>
		<content:encoded><![CDATA[<p>First of all, I want to thank you for the work you put into this.  It looks quite nice.  Also wanted to tell you that I found a bug in the code.  If a client sends to the server a partial message the server spins trying to read the message even do the client has disconnected.  It does not look like a bug in your code, it may be an issue in windows.  However this is what I did to reproduce.  I connected to the server using telnet and typed the following &#8220;1234567890&#8243;, the server read the first 4 bytes set it self to wait for a large message.  On the telnet side, I pressed ctrl+] and quited out of telnet.  The server stayed in a loop trying to read from client.</p>
<p>I read somewhere that selectors can only handle 64 sockets,  I can&#8217;t recall were I read this and as you said the doc on nio is spotty at best.  If it is so, what would you think is the best approach on your code to handle this.  1) create a thread for each selector or to process all the selectors using the same thread iterating threw the selectors ?</p>
<p>Thank You Again<br />
Diego Cassinera</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: adam</title>
		<link>http://t-machine.org/index.php/2008/01/22/java-nio-server-example/comment-page-1/#comment-1727</link>
		<dc:creator>adam</dc:creator>
		<pubDate>Mon, 14 Apr 2008 17:39:02 +0000</pubDate>
		<guid isPermaLink="false">http://tmachine1.dh.bytemark.co.uk/blog/index.php/2008/01/22/java-nio-server-example/#comment-1727</guid>
		<description>re: books - sorry, no. I started writing one a few years ago, and had a publishing contract etc sorted out, but in the end decided I didn&#039;t have enough time, so went back to concentrate fulltime on making them :).

The &quot;massively multiplayer game development&quot; books from CRM sound good on the cover, but are almost totally useless in fact, being full of mostly overly simplistic or even downright poor ideas and implementations. So I would suggest avoiding them. They&#039;re the most technical books I&#039;ve seen, though.

RAM is generally only a problem if you run out, and you&#039;ll know how much you need pretty quickly when you start developing. Any more detailed answer is going to take a LOT more detail to answer, sorry :).

For area-searching, I very much doubt it will be a major issue for you in the longrun, unless you&#039;re truly stupid with your implementation. Google for work on &quot;2d collision detection&quot; - it&#039;s the same problem, phrased slightly differently, and all modern games have good algorithms for this stuff already.

Database performance is usually the one that kills people...</description>
		<content:encoded><![CDATA[<p>re: books &#8211; sorry, no. I started writing one a few years ago, and had a publishing contract etc sorted out, but in the end decided I didn&#8217;t have enough time, so went back to concentrate fulltime on making them :).</p>
<p>The &#8220;massively multiplayer game development&#8221; books from CRM sound good on the cover, but are almost totally useless in fact, being full of mostly overly simplistic or even downright poor ideas and implementations. So I would suggest avoiding them. They&#8217;re the most technical books I&#8217;ve seen, though.</p>
<p>RAM is generally only a problem if you run out, and you&#8217;ll know how much you need pretty quickly when you start developing. Any more detailed answer is going to take a LOT more detail to answer, sorry :).</p>
<p>For area-searching, I very much doubt it will be a major issue for you in the longrun, unless you&#8217;re truly stupid with your implementation. Google for work on &#8220;2d collision detection&#8221; &#8211; it&#8217;s the same problem, phrased slightly differently, and all modern games have good algorithms for this stuff already.</p>
<p>Database performance is usually the one that kills people&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ephemeral</title>
		<link>http://t-machine.org/index.php/2008/01/22/java-nio-server-example/comment-page-1/#comment-1723</link>
		<dc:creator>ephemeral</dc:creator>
		<pubDate>Mon, 14 Apr 2008 12:58:44 +0000</pubDate>
		<guid isPermaLink="false">http://tmachine1.dh.bytemark.co.uk/blog/index.php/2008/01/22/java-nio-server-example/#comment-1723</guid>
		<description>Hello,

I am (with educational purposes) making a server for a MMORPG-game, that is supposed to be able to hold up to around 2000 players at once, so I got a few questions to ask:

1. Does the RAM-requirement (either if it is 30.000 kB or above 100.000 kB) have any visible impact on the servers efficiency?

2. What would be the best method to handle static game-data (XML files using XStream, or something else)?

3. What algorithm should preferrably be used for area-searching, to see which entities overlap the view-field of the current entity?

4. Do you know of any very good books about the subject MMORPG-game development for Java, or something covering other heavy server-frameworks?</description>
		<content:encoded><![CDATA[<p>Hello,</p>
<p>I am (with educational purposes) making a server for a MMORPG-game, that is supposed to be able to hold up to around 2000 players at once, so I got a few questions to ask:</p>
<p>1. Does the RAM-requirement (either if it is 30.000 kB or above 100.000 kB) have any visible impact on the servers efficiency?</p>
<p>2. What would be the best method to handle static game-data (XML files using XStream, or something else)?</p>
<p>3. What algorithm should preferrably be used for area-searching, to see which entities overlap the view-field of the current entity?</p>
<p>4. Do you know of any very good books about the subject MMORPG-game development for Java, or something covering other heavy server-frameworks?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: adam</title>
		<link>http://t-machine.org/index.php/2008/01/22/java-nio-server-example/comment-page-1/#comment-1702</link>
		<dc:creator>adam</dc:creator>
		<pubDate>Sat, 29 Mar 2008 21:59:27 +0000</pubDate>
		<guid isPermaLink="false">http://tmachine1.dh.bytemark.co.uk/blog/index.php/2008/01/22/java-nio-server-example/#comment-1702</guid>
		<description>@Michael - Hi. For a chess game, assuming standard two players per match, you should find this pretty easy, even with spectators; on a scale of one to ten, where 1 is &quot;singleplayer game&quot; and 10 is &quot;MMO FPS&quot;, I&#039;d rank this at around 3. The only complexities would be creating a lobby system and splitting the actual games across multiple servers. Any good programmer should be able to architect something for this - I&#039;d suggest reading the Gamasutra articles on RTS multiplayer games (although they&#039;re peer to peer, they&#039;re more than powerful enough for your needs, and feature good solutions for common problems and guidance on features you may not have thought of)

Then again, off the top of my head, I think the last online chess system I looked at had hundreds of thousands of simultaneously connected clients, so I suspect you should be able to find some good prior art that is chess specfic and more than adequate to your needs.

Happy to help with basic questions, but please note that I currently work for &lt;a href=&quot;http://ncsoft.com&quot; rel=&quot;nofollow&quot;&gt;one of the world&#039;s biggest massively multiplayer online game publishers / developers&lt;/a&gt;, so there are limits to how much I can get involved with other people&#039;s games - unless we&#039;re going to fund or publish them.</description>
		<content:encoded><![CDATA[<p>@Michael &#8211; Hi. For a chess game, assuming standard two players per match, you should find this pretty easy, even with spectators; on a scale of one to ten, where 1 is &#8220;singleplayer game&#8221; and 10 is &#8220;MMO FPS&#8221;, I&#8217;d rank this at around 3. The only complexities would be creating a lobby system and splitting the actual games across multiple servers. Any good programmer should be able to architect something for this &#8211; I&#8217;d suggest reading the Gamasutra articles on RTS multiplayer games (although they&#8217;re peer to peer, they&#8217;re more than powerful enough for your needs, and feature good solutions for common problems and guidance on features you may not have thought of)</p>
<p>Then again, off the top of my head, I think the last online chess system I looked at had hundreds of thousands of simultaneously connected clients, so I suspect you should be able to find some good prior art that is chess specfic and more than adequate to your needs.</p>
<p>Happy to help with basic questions, but please note that I currently work for <a href="http://ncsoft.com" onclick="javascript:pageTracker._trackPageview('/outbound/comment/http://ncsoft.com');" rel="nofollow">one of the world&#8217;s biggest massively multiplayer online game publishers / developers</a>, so there are limits to how much I can get involved with other people&#8217;s games &#8211; unless we&#8217;re going to fund or publish them.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://t-machine.org/index.php/2008/01/22/java-nio-server-example/comment-page-1/#comment-1698</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Sat, 29 Mar 2008 16:33:39 +0000</pubDate>
		<guid isPermaLink="false">http://tmachine1.dh.bytemark.co.uk/blog/index.php/2008/01/22/java-nio-server-example/#comment-1698</guid>
		<description>Hi there,
was interested by your post and project...
I am in the analysis phase of a big project to build a Internet Chess Server from Scratch that will eventually support 5.000 simult. users
could you please reply (using my email) so that we can talk a little about this framework and its suitability for such a project.
also interested in your skills

thanks</description>
		<content:encoded><![CDATA[<p>Hi there,<br />
was interested by your post and project&#8230;<br />
I am in the analysis phase of a big project to build a Internet Chess Server from Scratch that will eventually support 5.000 simult. users<br />
could you please reply (using my email) so that we can talk a little about this framework and its suitability for such a project.<br />
also interested in your skills</p>
<p>thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: adam</title>
		<link>http://t-machine.org/index.php/2008/01/22/java-nio-server-example/comment-page-1/#comment-1022</link>
		<dc:creator>adam</dc:creator>
		<pubDate>Tue, 22 Jan 2008 11:55:11 +0000</pubDate>
		<guid isPermaLink="false">http://tmachine1.dh.bytemark.co.uk/blog/index.php/2008/01/22/java-nio-server-example/#comment-1022</guid>
		<description>Andres - historically, MINA has been a complicated but severely under-documented API. AFAICS, the documentation is noticeably a lot better right now, but still appears to be missing vast chunks. Currently I do not have the time to deduce how to use someone else&#039;s complex architecture that is undocumented, no matter how powerful it may be :(. Once the documentation reaches a level that is equivalent to the complexity and richness of the library, I&#039;m hoping I&#039;ll have the chance to learn it properly.

Also ... this overly-simplistic implementation is quite easy (I think!) to read and understand and learn for yourself what is going on...</description>
		<content:encoded><![CDATA[<p>Andres &#8211; historically, MINA has been a complicated but severely under-documented API. AFAICS, the documentation is noticeably a lot better right now, but still appears to be missing vast chunks. Currently I do not have the time to deduce how to use someone else&#8217;s complex architecture that is undocumented, no matter how powerful it may be :(. Once the documentation reaches a level that is equivalent to the complexity and richness of the library, I&#8217;m hoping I&#8217;ll have the chance to learn it properly.</p>
<p>Also &#8230; this overly-simplistic implementation is quite easy (I think!) to read and understand and learn for yourself what is going on&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: adam</title>
		<link>http://t-machine.org/index.php/2008/01/22/java-nio-server-example/comment-page-1/#comment-1021</link>
		<dc:creator>adam</dc:creator>
		<pubDate>Tue, 22 Jan 2008 11:51:56 +0000</pubDate>
		<guid isPermaLink="false">http://tmachine1.dh.bytemark.co.uk/blog/index.php/2008/01/22/java-nio-server-example/#comment-1021</guid>
		<description>gareth - for instance, SelectionKey.attach() is still fundamentally broken AFAICS - it &quot;deletes&quot; the attachment if you do certain things, none of which is documented in the API, and you have to discover by trial and error - so that the entire method is mostly useless. IIRC the most detailed response I got from a Sun engineer was along the lines: &quot;well, that&#039;s because one of the underlying OS libraries we&#039;re using causes that, we&#039;re not going to work around it, so you ought to learn the OS-specific libraries we&#039;re implemetning - the JVM source is freely available, you know&quot;. WTF? Shrug.</description>
		<content:encoded><![CDATA[<p>gareth &#8211; for instance, SelectionKey.attach() is still fundamentally broken AFAICS &#8211; it &#8220;deletes&#8221; the attachment if you do certain things, none of which is documented in the API, and you have to discover by trial and error &#8211; so that the entire method is mostly useless. IIRC the most detailed response I got from a Sun engineer was along the lines: &#8220;well, that&#8217;s because one of the underlying OS libraries we&#8217;re using causes that, we&#8217;re not going to work around it, so you ought to learn the OS-specific libraries we&#8217;re implemetning &#8211; the JVM source is freely available, you know&#8221;. WTF? Shrug.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andres Quijano</title>
		<link>http://t-machine.org/index.php/2008/01/22/java-nio-server-example/comment-page-1/#comment-1019</link>
		<dc:creator>Andres Quijano</dc:creator>
		<pubDate>Tue, 22 Jan 2008 11:28:09 +0000</pubDate>
		<guid isPermaLink="false">http://tmachine1.dh.bytemark.co.uk/blog/index.php/2008/01/22/java-nio-server-example/#comment-1019</guid>
		<description>Using Apache MINA doesn&#039;t do the trick ?</description>
		<content:encoded><![CDATA[<p>Using Apache MINA doesn&#8217;t do the trick ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gareth</title>
		<link>http://t-machine.org/index.php/2008/01/22/java-nio-server-example/comment-page-1/#comment-1017</link>
		<dc:creator>gareth</dc:creator>
		<pubDate>Tue, 22 Jan 2008 10:31:23 +0000</pubDate>
		<guid isPermaLink="false">http://tmachine1.dh.bytemark.co.uk/blog/index.php/2008/01/22/java-nio-server-example/#comment-1017</guid>
		<description>more stuff on nio is always welcome in my book :)

i am very interested to know exactly what the &quot;few major flaws and a few unfixed bugs&quot; are - as much as i dont really like the api, my game im making seems to be working ok so far - i mostly used online tutorials to help me learn nio. Only thing i can thing of is maybe a lack of built in timeout handling?</description>
		<content:encoded><![CDATA[<p>more stuff on nio is always welcome in my book :)</p>
<p>i am very interested to know exactly what the &#8220;few major flaws and a few unfixed bugs&#8221; are &#8211; as much as i dont really like the api, my game im making seems to be working ok so far &#8211; i mostly used online tutorials to help me learn nio. Only thing i can thing of is maybe a lack of built in timeout handling?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
