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