Skip to content

Commit

Permalink
impr
Browse files Browse the repository at this point in the history
  • Loading branch information
szysas committed Aug 28, 2024
1 parent e660415 commit 37fb763
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.epoll.EpollChannelOption;
import io.netty.channel.epoll.EpollDatagramChannel;
import io.netty.channel.epoll.EpollEventLoopGroup;
import io.netty.channel.socket.DatagramChannel;
import io.netty.channel.unix.UnixChannelOption;
import io.netty.util.concurrent.DefaultThreadFactory;
import java.io.IOException;
import java.net.InetSocketAddress;
Expand Down Expand Up @@ -83,7 +83,7 @@ protected void initChannel(DatagramChannel ch) {
.group(eventLoopGroup)
.localAddress(serverPort)
.channel(EpollDatagramChannel.class)
.option(EpollChannelOption.SO_REUSEPORT, true)
.option(UnixChannelOption.SO_REUSEPORT, true)
.handler(new ChannelInitializer<DatagramChannel>() {
@Override
protected void initChannel(DatagramChannel ch) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
import com.mbed.coap.server.RouterService;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.DatagramChannel;
import io.netty.channel.socket.nio.NioDatagramChannel;
import io.netty.channel.unix.UnixChannelOption;
import io.netty.util.concurrent.DefaultThreadFactory;
import org.junit.jupiter.api.Test;

Expand All @@ -45,7 +45,6 @@ void test() throws Exception {
CoapServerBuilder builder = CoapServer.builder()
.route(RouterService.builder()
.get("/test", __ -> ok("OK").toFuture())
.post("/echo", req -> ok(req.getPayload()).toFuture())
);

MultiCoapServer coapServer = MultiCoapServer.create(builder, createBootstrap(0));
Expand All @@ -65,7 +64,7 @@ void test() throws Exception {
private Bootstrap createBootstrap(int port) {
return new Bootstrap()
.group(eventLoopGroup)
.option(ChannelOption.SO_REUSEADDR, true)
.option(UnixChannelOption.SO_REUSEPORT, true)
.localAddress(port)
.channel(NioDatagramChannel.class)
.handler(new ChannelInitializer<DatagramChannel>() {
Expand Down

0 comments on commit 37fb763

Please sign in to comment.