1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty5.example.qotm;
17
18 import io.netty5.bootstrap.Bootstrap;
19 import io.netty5.channel.ChannelOption;
20 import io.netty5.channel.EventLoopGroup;
21 import io.netty5.channel.MultithreadEventLoopGroup;
22 import io.netty5.channel.nio.NioHandler;
23 import io.netty5.channel.socket.nio.NioDatagramChannel;
24
25
26
27
28
29
30
31 public final class QuoteOfTheMomentServer {
32
33 private static final int PORT = Integer.parseInt(System.getProperty("port", "7686"));
34
35 public static void main(String[] args) throws Exception {
36 EventLoopGroup group = new MultithreadEventLoopGroup(NioHandler.newFactory());
37 try {
38 Bootstrap b = new Bootstrap();
39 b.group(group)
40 .channel(NioDatagramChannel.class)
41 .option(ChannelOption.SO_BROADCAST, true)
42 .handler(new QuoteOfTheMomentServerHandler());
43
44 b.bind(PORT).asStage().get().closeFuture().asStage().await();
45 } finally {
46 group.shutdownGracefully();
47 }
48 }
49 }