Home / Function/ Channel() — netty Function Reference

Channel() — netty Function Reference

Architecture documentation for the Channel() function in DatagramUnicastInetTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  3f54518d_238f_17f2_7d87_05c6651a1886["Channel()"]
  f0d69a11_922d_d577_4c42_91055296d6a7["DatagramUnicastInetTest"]
  3f54518d_238f_17f2_7d87_05c6651a1886 -->|defined in| f0d69a11_922d_d577_4c42_91055296d6a7
  style 3f54518d_238f_17f2_7d87_05c6651a1886 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

testsuite/src/main/java/io/netty/testsuite/transport/socket/DatagramUnicastInetTest.java lines 66–98

    @Override
    protected Channel setupClientChannel(Bootstrap cb, final byte[] bytes, final CountDownLatch latch,
                                         final AtomicReference<Throwable> errorRef) throws Throwable {
        cb.handler(new SimpleChannelInboundHandler<DatagramPacket>() {

            @Override
            public void channelRead0(ChannelHandlerContext ctx, DatagramPacket msg) {
                try {
                    ByteBuf buf = msg.content();
                    assertEquals(bytes.length, buf.readableBytes());
                    for (int i = 0; i < bytes.length; i++) {
                        assertEquals(bytes[i], buf.getByte(buf.readerIndex() + i));
                    }

                    InetSocketAddress localAddress = (InetSocketAddress) ctx.channel().localAddress();
                    if (localAddress.getAddress().isAnyLocalAddress()) {
                        assertEquals(localAddress.getPort(), msg.recipient().getPort());
                    } else {
                        // Test that the channel's localAddress is equal to the message's recipient
                        assertEquals(localAddress, msg.recipient());
                    }
                } finally {
                    latch.countDown();
                }
            }

            @Override
            public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
                errorRef.compareAndSet(null, cause);
            }
        });
        return cb.bind(newSocketAddress()).sync().channel();
    }

Domain

Subdomains

Frequently Asked Questions

What does Channel() do?
Channel() is a function in the netty codebase, defined in testsuite/src/main/java/io/netty/testsuite/transport/socket/DatagramUnicastInetTest.java.
Where is Channel() defined?
Channel() is defined in testsuite/src/main/java/io/netty/testsuite/transport/socket/DatagramUnicastInetTest.java at line 66.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free