Home / Function/ doConnect0() — netty Function Reference

doConnect0() — netty Function Reference

Architecture documentation for the doConnect0() function in KQueueSocketChannel.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  3372d5b2_fe82_439d_7237_945f315cff90["doConnect0()"]
  41b30e57_b9d4_3e06_970a_c190f122cd7f["KQueueSocketChannel"]
  3372d5b2_fe82_439d_7237_945f315cff90 -->|defined in| 41b30e57_b9d4_3e06_970a_c190f122cd7f
  style 3372d5b2_fe82_439d_7237_945f315cff90 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

transport-classes-kqueue/src/main/java/io/netty/channel/kqueue/KQueueSocketChannel.java lines 84–111

    @Override
    protected boolean doConnect0(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception {
        if (config.isTcpFastOpenConnect()) {
            ChannelOutboundBuffer outbound = unsafe().outboundBuffer();
            outbound.addFlush();
            Object curr;
            if ((curr = outbound.current()) instanceof ByteBuf) {
                ByteBuf initialData = (ByteBuf) curr;
                // Don't bother with TCP FastOpen if we don't have any initial data to send anyway.
                if (initialData.isReadable()) {
                    IovArray iov = new IovArray(config.getAllocator().directBuffer());
                    try {
                        iov.add(initialData, initialData.readerIndex(), initialData.readableBytes());
                        int bytesSent = socket.connectx(
                                (InetSocketAddress) localAddress, (InetSocketAddress) remoteAddress, iov, true);
                        writeFilter(true);
                        outbound.removeBytes(Math.abs(bytesSent));
                        // The `connectx` method returns a negative number if connection is in-progress.
                        // So we should return `true` to indicate that connection was established, if it's positive.
                        return bytesSent > 0;
                    } finally {
                        iov.release();
                    }
                }
            }
        }
        return super.doConnect0(remoteAddress, localAddress);
    }

Domain

Subdomains

Frequently Asked Questions

What does doConnect0() do?
doConnect0() is a function in the netty codebase, defined in transport-classes-kqueue/src/main/java/io/netty/channel/kqueue/KQueueSocketChannel.java.
Where is doConnect0() defined?
doConnect0() is defined in transport-classes-kqueue/src/main/java/io/netty/channel/kqueue/KQueueSocketChannel.java at line 84.

Analyze Your Own Codebase

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

Try Supermodel Free