bug修复
This commit is contained in:
parent
bfbf1b721a
commit
3d4f839c04
@ -25,27 +25,27 @@ public class UDPServerApp {
|
||||
|
||||
@PostConstruct
|
||||
public void startUdpApp() {
|
||||
if (port == null) {
|
||||
return;
|
||||
}
|
||||
log.info("启动udp中……");
|
||||
Bootstrap bootstrap = new Bootstrap();
|
||||
EventLoopGroup workGroup = new NioEventLoopGroup();
|
||||
bootstrap.group(workGroup).channel(NioDatagramChannel.class)
|
||||
.option(ChannelOption.SO_BROADCAST, true)
|
||||
.handler(new ChannelInitializer<NioDatagramChannel>() {
|
||||
if (port == null) {
|
||||
return;
|
||||
}
|
||||
log.info("启动udp中……");
|
||||
Bootstrap bootstrap = new Bootstrap();
|
||||
EventLoopGroup workGroup = new NioEventLoopGroup();
|
||||
bootstrap.group(workGroup).channel(NioDatagramChannel.class)
|
||||
.option(ChannelOption.SO_BROADCAST, true)
|
||||
.handler(new ChannelInitializer<NioDatagramChannel>() {
|
||||
|
||||
@Override
|
||||
protected void initChannel(NioDatagramChannel ch) throws Exception {
|
||||
ch.pipeline().addLast(udpServerHandler);
|
||||
}
|
||||
});
|
||||
try {
|
||||
Channel channel = bootstrap.bind("127.0.0.1", port).sync().channel();
|
||||
//channel.closeFuture().sync().await();
|
||||
log.info("启动udp成功……");
|
||||
} catch (Exception e) {
|
||||
log.error("udp启动err:", e);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void initChannel(NioDatagramChannel ch) throws Exception {
|
||||
ch.pipeline().addLast(udpServerHandler);
|
||||
}
|
||||
});
|
||||
try {
|
||||
Channel channel = bootstrap.bind(port).sync().channel();
|
||||
//channel.closeFuture().sync().await();
|
||||
log.info("启动udp成功,端口:{}", port);
|
||||
} catch (Exception e) {
|
||||
log.error("udp启动err:", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user