EpollServerSocketUnsafe Class — netty Architecture
Architecture documentation for the EpollServerSocketUnsafe class in AbstractEpollServerChannel.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD a777fbd3_8623_9136_b37a_d54e5a77a917["EpollServerSocketUnsafe"] 7b3f3725_abfa_064b_80f8_409f318cca4c["AbstractEpollServerChannel.java"] a777fbd3_8623_9136_b37a_d54e5a77a917 -->|defined in| 7b3f3725_abfa_064b_80f8_409f318cca4c 82f2f4ce_2af2_8024_1095_e7bc55ce4f9b["connect()"] a777fbd3_8623_9136_b37a_d54e5a77a917 -->|method| 82f2f4ce_2af2_8024_1095_e7bc55ce4f9b c8a4d77a_691c_a46b_5154_b2e603435216["epollInReady()"] a777fbd3_8623_9136_b37a_d54e5a77a917 -->|method| c8a4d77a_691c_a46b_5154_b2e603435216
Relationship Graph
Source Code
transport-classes-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollServerChannel.java lines 71–128
final class EpollServerSocketUnsafe extends AbstractEpollUnsafe {
// Will hold the remote address after accept(...) was successful.
// We need 24 bytes for the address as maximum + 1 byte for storing the length.
private final byte[] acceptedAddress = new byte[25];
@Override
public void connect(SocketAddress socketAddress, SocketAddress socketAddress2, ChannelPromise channelPromise) {
// Connect not supported by ServerChannel implementations
channelPromise.setFailure(new UnsupportedOperationException());
}
@Override
void epollInReady() {
assert eventLoop().inEventLoop();
final ChannelConfig config = config();
if (shouldBreakEpollInReady(config)) {
clearEpollIn0();
return;
}
final EpollRecvByteAllocatorHandle allocHandle = recvBufAllocHandle();
final ChannelPipeline pipeline = pipeline();
allocHandle.reset(config);
allocHandle.attemptedBytesRead(1);
Throwable exception = null;
try {
try {
do {
// lastBytesRead represents the fd. We use lastBytesRead because it must be set so that the
// EpollRecvByteAllocatorHandle knows if it should try to read again or not when autoRead is
// enabled.
allocHandle.lastBytesRead(socket.accept(acceptedAddress));
if (allocHandle.lastBytesRead() == -1) {
// this means everything was handled for now
break;
}
allocHandle.incMessagesRead(1);
readPending = false;
pipeline.fireChannelRead(newChildChannel(allocHandle.lastBytesRead(), acceptedAddress, 1,
acceptedAddress[0]));
} while (allocHandle.continueReading());
} catch (Throwable t) {
exception = t;
}
allocHandle.readComplete();
pipeline.fireChannelReadComplete();
if (exception != null) {
pipeline.fireExceptionCaught(exception);
}
} finally {
if (shouldStopReading(config)) {
clearEpollIn();
}
}
}
}
Defined In
Source
Frequently Asked Questions
What is the EpollServerSocketUnsafe class?
EpollServerSocketUnsafe is a class in the netty codebase, defined in transport-classes-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollServerChannel.java.
Where is EpollServerSocketUnsafe defined?
EpollServerSocketUnsafe is defined in transport-classes-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollServerChannel.java at line 71.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free