更改发送报文时 绑定的端口

This commit is contained in:
2024-12-01 16:40:19 +08:00
parent f379b02e61
commit 6203c43ebe
2 changed files with 9 additions and 11 deletions

View File

@ -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();

View File

@ -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);
}
}