package com.example.videonetty;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.Channel;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel;
public class TcpClient extends Thread {
public static String HOST = "168.168.1.121";
public static int PORT = 9999;
public void run() {
super.run();
EventLoopGroup group = new NioEventLoopGroup();
try {
Bootstrap bootstrap = new Bootstrap()
.group(group)
.channel(NioSocketChannel.class)
.handler(new SimpleChatClientInitializer());
Channel channel = bootstrap.connect(HOST, PORT).sync().channel();
while(true){
channel.writeAndFlush("this msg test come from client" "\r\n");
Thread.currentThread();
Thread.sleep(1000);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
group.shutdownGracefully();
}
}
}
资源文件列表
AndroidNetty.rar , 6982024
JavaNettyProj4.rar , 8253
