Created
April 20, 2013 23:33
-
-
Save roooodcastro/5427837 to your computer and use it in GitHub Desktop.
Configuração ClienteTCP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int PORTA_CLIENTE_TCP = 1050; | |
public void iniciarServidorTCP() { | |
fabrica = new NioServerSocketChannelFactory(Executors.newCachedThreadPool(),Executors.newCachedThreadPool()); | |
bootstrap = new ServerBootstrap(fabrica); | |
bootstrap.setPipelineFactory(new ChannelPipelineFactory() { | |
@Override | |
public ChannelPipeline getPipeline() throws Exception { | |
ChannelPipeline pipeline = Channels.pipeline(); | |
pipeline.addLast("decoderDeMensagem", new MensagemDecoderTCP()); | |
pipeline.addLast("handlerGerente", new GerenteTCP()); | |
pipeline.addLast("encoder de mensagem", new MensagemEncoderTCP()); | |
return pipeline; | |
} | |
}); | |
bootstrap.setOption("child.tcpNoDelay", true); | |
// bootstrap.setOption("child.keepAlive", true); | |
bootstrap.setOption("child.reuseAddress", true); | |
// bootstrap.setOption("child.connectTimeoutMillis", 100); | |
// bootstrap.setOption("readWriteFair", true); | |
bootstrap.bind(new InetSocketAddress(PORTA_CLIENTE_TCP)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment