更改发送报文时 绑定的端口
This commit is contained in:
@ -18,14 +18,14 @@ public class RIPService {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
// 启动服务器
|
||||
RIPServer server = new RIPServer();
|
||||
new Thread(() -> {
|
||||
try {
|
||||
server.start();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
// RIPServer server = new RIPServer();
|
||||
// new Thread(() -> {
|
||||
// try {
|
||||
// server.start();
|
||||
// } catch (InterruptedException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }).start();
|
||||
|
||||
// 启动客户端
|
||||
RIPClient client = new RIPClient();
|
||||
|
@ -36,14 +36,12 @@ public class RIPClient {
|
||||
|
||||
public void sendRipPacket(RIPPacket packet) {
|
||||
try {
|
||||
ChannelFuture future = bootstrap.bind(InetAddress.getByName("192.168.123.45"), 520)
|
||||
ChannelFuture future = bootstrap.bind(0)
|
||||
.sync();
|
||||
future.channel().writeAndFlush(packet).sync();
|
||||
future.channel().close();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
} catch (UnknownHostException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user