use of org.ko.netty.t3.initializer.ClientChannelInitializer in project tutorials-java by Artister.
the class HelloWorldClient method start.
public void start() {
EventLoopGroup group = new NioEventLoopGroup();
Bootstrap bootstrap = new Bootstrap();
bootstrap.group(group).channel(NioSocketChannel.class).handler(new ClientChannelInitializer());
try {
ChannelFuture future = bootstrap.connect(address, port).sync();
future.channel().closeFuture().sync();
} catch (Exception e) {
e.printStackTrace();
} finally {
group.shutdownGracefully();
}
}
use of org.ko.netty.t3.initializer.ClientChannelInitializer in project tutorials-java by Artister.
the class HelloWorldClient method start.
public void start() {
EventLoopGroup group = new NioEventLoopGroup();
Bootstrap bootstrap = new Bootstrap();
bootstrap.group(group).channel(NioSocketChannel.class).handler(new ClientChannelInitializer());
try {
Channel channel = bootstrap.connect(address, port).sync().channel();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
for (; ; ) {
String msg = reader.readLine();
if (msg == null) {
continue;
}
channel.writeAndFlush(msg + "\r\n");
}
} catch (Exception e) {
e.printStackTrace();
} finally {
group.shutdownGracefully();
}
}
use of org.ko.netty.t3.initializer.ClientChannelInitializer in project tutorials-java by Artister.
the class HwClient method start.
public void start() {
EventLoopGroup group = new NioEventLoopGroup();
Bootstrap bootstrap = new Bootstrap();
bootstrap.group(group).channel(NioSocketChannel.class).handler(new ClientChannelInitializer());
try {
ChannelFuture future = bootstrap.connect(address, port).sync();
future.channel().writeAndFlush("Hello Netty Server ,I am a common client");
future.channel().closeFuture().sync();
} catch (Exception e) {
e.printStackTrace();
} finally {
group.shutdownGracefully();
}
}
Aggregations