KQueueSocketChannel Class — netty Architecture
Architecture documentation for the KQueueSocketChannel class in KQueueSocketChannel.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 41b30e57_b9d4_3e06_970a_c190f122cd7f["KQueueSocketChannel"] aa6e4f51_9cb6_4d73_ecd4_16bd8179baaf["KQueueSocketChannel.java"] 41b30e57_b9d4_3e06_970a_c190f122cd7f -->|defined in| aa6e4f51_9cb6_4d73_ecd4_16bd8179baaf 211e92e6_3f02_fd89_f532_fb625e20036c["KQueueSocketChannel()"] 41b30e57_b9d4_3e06_970a_c190f122cd7f -->|method| 211e92e6_3f02_fd89_f532_fb625e20036c 6f15bc20_16b4_0d34_3ee7_30b5db48c812["InetSocketAddress()"] 41b30e57_b9d4_3e06_970a_c190f122cd7f -->|method| 6f15bc20_16b4_0d34_3ee7_30b5db48c812 8de17e46_8a54_e65e_5159_eca0dd7260d4["KQueueSocketChannelConfig()"] 41b30e57_b9d4_3e06_970a_c190f122cd7f -->|method| 8de17e46_8a54_e65e_5159_eca0dd7260d4 a1f9a9fb_55e4_7c33_b824_2769f8726907["ServerSocketChannel()"] 41b30e57_b9d4_3e06_970a_c190f122cd7f -->|method| a1f9a9fb_55e4_7c33_b824_2769f8726907 3372d5b2_fe82_439d_7237_945f315cff90["doConnect0()"] 41b30e57_b9d4_3e06_970a_c190f122cd7f -->|method| 3372d5b2_fe82_439d_7237_945f315cff90 059ce86e_fecd_34d7_9a8c_ed32746293c9["AbstractKQueueUnsafe()"] 41b30e57_b9d4_3e06_970a_c190f122cd7f -->|method| 059ce86e_fecd_34d7_9a8c_ed32746293c9
Relationship Graph
Source Code
transport-classes-kqueue/src/main/java/io/netty/channel/kqueue/KQueueSocketChannel.java lines 32–140
public final class KQueueSocketChannel extends AbstractKQueueStreamChannel implements SocketChannel {
private final KQueueSocketChannelConfig config;
public KQueueSocketChannel() {
super(null, BsdSocket.newSocketStream(), false);
config = new KQueueSocketChannelConfig(this);
}
/**
* @deprecated use {@link KQueueDatagramChannel(SocketProtocolFamily)}
*/
@Deprecated
public KQueueSocketChannel(InternetProtocolFamily protocol) {
super(null, BsdSocket.newSocketStream(protocol), false);
config = new KQueueSocketChannelConfig(this);
}
public KQueueSocketChannel(SocketProtocolFamily protocol) {
super(null, BsdSocket.newSocketStream(protocol), false);
config = new KQueueSocketChannelConfig(this);
}
public KQueueSocketChannel(int fd) {
super(new BsdSocket(fd));
config = new KQueueSocketChannelConfig(this);
}
KQueueSocketChannel(Channel parent, BsdSocket fd, InetSocketAddress remoteAddress) {
super(parent, fd, remoteAddress);
config = new KQueueSocketChannelConfig(this);
}
@Override
public InetSocketAddress remoteAddress() {
return (InetSocketAddress) super.remoteAddress();
}
@Override
public InetSocketAddress localAddress() {
return (InetSocketAddress) super.localAddress();
}
@Override
public KQueueSocketChannelConfig config() {
return config;
}
@Override
public ServerSocketChannel parent() {
return (ServerSocketChannel) super.parent();
}
@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);
}
Source
Frequently Asked Questions
What is the KQueueSocketChannel class?
KQueueSocketChannel is a class in the netty codebase, defined in transport-classes-kqueue/src/main/java/io/netty/channel/kqueue/KQueueSocketChannel.java.
Where is KQueueSocketChannel defined?
KQueueSocketChannel is defined in transport-classes-kqueue/src/main/java/io/netty/channel/kqueue/KQueueSocketChannel.java at line 32.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free