main() — netty Function Reference
Architecture documentation for the main() function in Http3ClientExample.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 409cb9bc_453a_ab7d_24c8_f2ea25d3a0da["main()"] 0ae7f510_86e0_e911_d0aa_4496103975a1["Http3ClientExample"] 409cb9bc_453a_ab7d_24c8_f2ea25d3a0da -->|defined in| 0ae7f510_86e0_e911_d0aa_4496103975a1 style 409cb9bc_453a_ab7d_24c8_f2ea25d3a0da fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-http3/src/test/java/io/netty/handler/codec/http3/example/Http3ClientExample.java lines 47–111
public static void main(String... args) throws Exception {
EventLoopGroup group = new MultiThreadIoEventLoopGroup(1, NioIoHandler.newFactory());
try {
QuicSslContext context = QuicSslContextBuilder.forClient()
.trustManager(InsecureTrustManagerFactory.INSTANCE)
.applicationProtocols(Http3.supportedApplicationProtocols()).build();
ChannelHandler codec = Http3.newQuicClientCodecBuilder()
.sslContext(context)
.maxIdleTimeout(5000, TimeUnit.MILLISECONDS)
.initialMaxData(10000000)
.initialMaxStreamDataBidirectionalLocal(1000000)
.build();
Bootstrap bs = new Bootstrap();
Channel channel = bs.group(group)
.channel(NioDatagramChannel.class)
.handler(codec)
.bind(0).sync().channel();
QuicChannel quicChannel = QuicChannel.newBootstrap(channel)
.handler(new Http3ClientConnectionHandler())
.remoteAddress(new InetSocketAddress(NetUtil.LOCALHOST4, Http3ServerExample.PORT))
.connect()
.get();
QuicStreamChannel streamChannel = Http3.newRequestStream(quicChannel,
new Http3RequestStreamInboundHandler() {
@Override
protected void channelRead(ChannelHandlerContext ctx, Http3HeadersFrame frame) {
ReferenceCountUtil.release(frame);
}
@Override
protected void channelRead(ChannelHandlerContext ctx, Http3DataFrame frame) {
System.err.print(frame.content().toString(CharsetUtil.US_ASCII));
ReferenceCountUtil.release(frame);
}
@Override
protected void channelInputClosed(ChannelHandlerContext ctx) {
ctx.close();
}
}).sync().getNow();
// Write the Header frame and send the FIN to mark the end of the request.
// After this its not possible anymore to write any more data.
Http3HeadersFrame frame = new DefaultHttp3HeadersFrame();
frame.headers().method("GET").path("/")
.authority(NetUtil.LOCALHOST4.getHostAddress() + ":" + Http3ServerExample.PORT)
.scheme("https");
streamChannel.writeAndFlush(frame)
.addListener(QuicStreamChannel.SHUTDOWN_OUTPUT).sync();
// Wait for the stream channel and quic channel to be closed (this will happen after we received the FIN).
// After this is done we will close the underlying datagram channel.
streamChannel.closeFuture().sync();
// After we received the response lets also close the underlying QUIC channel and datagram channel.
quicChannel.close().sync();
channel.close().sync();
} finally {
group.shutdownGracefully();
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does main() do?
main() is a function in the netty codebase, defined in codec-http3/src/test/java/io/netty/handler/codec/http3/example/Http3ClientExample.java.
Where is main() defined?
main() is defined in codec-http3/src/test/java/io/netty/handler/codec/http3/example/Http3ClientExample.java at line 47.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free