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