List of usage examples for io.netty.channel.udt.nio NioUdtProvider MESSAGE_CONNECTOR
ChannelFactory MESSAGE_CONNECTOR
To view the source code for io.netty.channel.udt.nio NioUdtProvider MESSAGE_CONNECTOR.
Click Source Link
From source file:com.flysoloing.learning.network.netty.udt.echo.message.MsgEchoClient.java
License:Apache License
public static void main(String[] args) throws Exception { // Configure the client. final ThreadFactory connectFactory = new DefaultThreadFactory("connect"); final NioEventLoopGroup connectGroup = new NioEventLoopGroup(1, connectFactory, NioUdtProvider.MESSAGE_PROVIDER); try {/*w w w . ja v a2 s . c o m*/ final Bootstrap boot = new Bootstrap(); boot.group(connectGroup).channelFactory(NioUdtProvider.MESSAGE_CONNECTOR) .handler(new ChannelInitializer<UdtChannel>() { @Override public void initChannel(final UdtChannel ch) throws Exception { ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO), new MsgEchoClientHandler()); } }); // Start the client. final ChannelFuture f = boot.connect(HOST, PORT).sync(); // Wait until the connection is closed. f.channel().closeFuture().sync(); } finally { // Shut down the event loop to terminate all threads. connectGroup.shutdownGracefully(); } }
From source file:com.seagate.kinetic.client.io.provider.nio.udt.UdtTransportProvider.java
License:Open Source License
private void initTransport() throws KineticException { this.port = this.config.getPort(); this.host = this.config.getHost(); try {//from w ww.j av a2 s . c om workerGroup = UdtWorkerGroup.getWorkerGroup(); udtChannelInitializer = new UdtClientChannelInitializer(this.mservice); bootstrap = new Bootstrap(); bootstrap.group(workerGroup).channelFactory(NioUdtProvider.MESSAGE_CONNECTOR) .option(ChannelOption.SO_REUSEADDR, true).handler(udtChannelInitializer); channel = bootstrap.connect(host, port).sync().channel(); } catch (Exception e) { throw new KineticException(e); } logger.info("udt client connected to host:port =" + host + ":" + port); }
From source file:io.aos.netty5.udt.echo.message.MsgEchoClient.java
License:Apache License
public static void main(String[] args) throws Exception { // Configure the client. final ExecutorServiceFactory connectFactory = new DefaultExecutorServiceFactory("connect"); final NioEventLoopGroup connectGroup = new NioEventLoopGroup(1, connectFactory, NioUdtProvider.MESSAGE_PROVIDER); try {/*from www.j av a 2s . c om*/ final Bootstrap boot = new Bootstrap(); boot.group(connectGroup).channelFactory(NioUdtProvider.MESSAGE_CONNECTOR) .handler(new ChannelInitializer<UdtChannel>() { @Override public void initChannel(final UdtChannel ch) throws Exception { ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO), new MsgEchoClientHandler()); } }); // Start the client. final ChannelFuture f = boot.connect(HOST, PORT).sync(); // Wait until the connection is closed. f.channel().closeFuture().sync(); } finally { // Shut down the event loop to terminate all threads. connectGroup.shutdownGracefully(); } }