title: Multiple Netty Clients sending data to one Netty server
body: <p>I am using Netty 3.9.5 and I have a simple client server setup which I got from <a href="http://en.wikipedia.org/wiki/Netty_%28software%29#Netty_TCP_Example" rel="nofollow">http://en.wikipedia.org/wiki/Netty_%28software%29#Netty_TCP_Example</a>. I have expanded the example to send a Java search plan object from the client to the server.  With help from follow users on this site, I have been able to get this program to function as desired.</p>
  
  <p>I now want to have my reader/server program accept multiple clients at the same time.  I thought I would take my original pipeline factory code listed below:</p>
  
  <pre><code>channelFactory = new NioServerSocketChannelFactory(bossThreadPool,
              workerThreadPool);
      this.bootstrap = new ServerBootstrap(channelFactory);
      this.bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
          @Override
          public ChannelPipeline getPipeline() throws Exception {
              return Channels.pipeline(
                      new ObjectEncoder(),
                      new ObjectDecoder(ClassResolvers
                              .cacheDisabled(getClass().getClassLoader())),
                      new ServerMessageHandler());
          }
      });
  </code></pre>
  
  <p>and make this change:</p>
  
  <pre><code>channelFactory = new NioServerSocketChannelFactory(bossThreadPool,workerThreadPool, 3);
  </code></pre>
  
  <p>I thought this would create 3 worker threads within the workerThreadPool, which in turn would be able to handle 3 client connections.  This does not work.  The first client connection works as expected but the 2nd connection eventually throws a connect timeout exception.</p>
  
  <p>Questions:</p>
  
  <ol>
  <li>Is my assumption about the workerThreadPool correct and if yes, what did I forget? </li>
  <li><p>Right now my code still only uses one port for the connect.  Do I need a unique port for each possible connection?  I have not seen an example of this.  Do I need to tweak the bind method or the acceptor.isBound method for possible multiple connections?</p>
  
  <pre><code>public boolean connect() {
  boolean status = false; // assume failure
  
  final int LISTEN_PORT = 53233;
  
  /*
   * We use a channel when attempting to bind the ServerBootstrap to
   * ensure if the operation was successful
   */
  acceptor = this.bootstrap.bind(new InetSocketAddress(LISTEN_PORT));
  
  /*
   * We make sure the Server could bind to the port by calling the
   * isBound() method in the Channel class.
   */
  if (!acceptor.isBound()) {
      logger.error(ErrorMessage.SERVER_UNABLE_TO_BIND + LISTEN_PORT);
  
      status = false;
  } else {
      status = true;
      logger.info(Message.SERVER_CONNECTION_SUCCESSFUL + LISTEN_PORT
              + "!" + Message.SERVER_AWAITING_CONNECTIONS);
  }
  
  return status;
  }
  </code></pre></li>
  </ol>
  
  <p>Any help would be deeply appreciated.
  Thanks</p>