public virtual void Run() { // Configure the client. ChannelFactory factory = new NioClientSocketChannelFactory(Executors.NewCachedThreadPool (), Executors.NewCachedThreadPool(), 1, 1); ClientBootstrap bootstrap = new ClientBootstrap(factory); // Set up the pipeline factory. bootstrap.SetPipelineFactory(SetPipelineFactory()); bootstrap.SetOption("tcpNoDelay", true); bootstrap.SetOption("keepAlive", true); // Start the connection attempt. ChannelFuture future = bootstrap.Connect(new IPEndPoint(host, port)); if (oneShot) { // Wait until the connection is closed or the connection attempt fails. future.GetChannel().GetCloseFuture().AwaitUninterruptibly(); // Shut down thread pools to exit. bootstrap.ReleaseExternalResources(); } }