tcpV4() — netty Function Reference
Architecture documentation for the tcpV4() function in PcapWriteHandlerTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD d05177b8_4cad_27b7_df18_d8a758cd2b20["tcpV4()"] e9f4993c_4935_9405_4fab_0bbc9030a673["PcapWriteHandlerTest"] d05177b8_4cad_27b7_df18_d8a758cd2b20 -->|defined in| e9f4993c_4935_9405_4fab_0bbc9030a673 baf4f2f7_a515_8987_badd_9a8496a598e4["tcpV4SharedOutputStreamTest()"] baf4f2f7_a515_8987_badd_9a8496a598e4 -->|calls| d05177b8_4cad_27b7_df18_d8a758cd2b20 02356582_4737_80ce_da1e_1f15aa33b632["tcpV4NoGlobalHeaderOutputStream()"] 02356582_4737_80ce_da1e_1f15aa33b632 -->|calls| d05177b8_4cad_27b7_df18_d8a758cd2b20 4e2781b5_ce88_1326_dbe9_36b13e2532e5["tcpV4NonOutputStream()"] 4e2781b5_ce88_1326_dbe9_36b13e2532e5 -->|calls| d05177b8_4cad_27b7_df18_d8a758cd2b20 69e66b7a_8463_4459_62cd_204ac977b046["channelRead()"] d05177b8_4cad_27b7_df18_d8a758cd2b20 -->|calls| 69e66b7a_8463_4459_62cd_204ac977b046 201e7e9e_c23c_b328_ecb1_117026fc1c03["InetSocketAddress()"] d05177b8_4cad_27b7_df18_d8a758cd2b20 -->|calls| 201e7e9e_c23c_b328_ecb1_117026fc1c03 a21dcafa_3fd5_25fa_9ab3_64ba75a8e86a["verifyTcpHandshakeCapture()"] d05177b8_4cad_27b7_df18_d8a758cd2b20 -->|calls| a21dcafa_3fd5_25fa_9ab3_64ba75a8e86a d3cfaa8b_8ac2_24f3_97d5_6f3a794d3ad8["verifyTcpCapture()"] d05177b8_4cad_27b7_df18_d8a758cd2b20 -->|calls| d3cfaa8b_8ac2_24f3_97d5_6f3a794d3ad8 48f0964c_1c25_e316_603f_d8c514e3fbc2["verifyTcpCloseCapture()"] d05177b8_4cad_27b7_df18_d8a758cd2b20 -->|calls| 48f0964c_1c25_e316_603f_d8c514e3fbc2 style d05177b8_4cad_27b7_df18_d8a758cd2b20 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
handler/src/test/java/io/netty/handler/pcap/PcapWriteHandlerTest.java lines 475–596
private static void tcpV4(final boolean sharedOutputStream, final boolean writeGlobalHeaders) throws Exception {
final ByteBuf byteBuf = Unpooled.buffer();
final ByteBuf payload = Unpooled.wrappedBuffer("Meow".getBytes());
try {
EventLoopGroup group = new MultiThreadIoEventLoopGroup(1, NioIoHandler.newFactory());
// Configure the echo server
ServerBootstrap sb = new ServerBootstrap();
final CountDownLatch serverLatch = new CountDownLatch(1);
sb.group(group)
.channel(NioServerSocketChannel.class)
.option(ChannelOption.SO_BACKLOG, 100)
.childHandler(new ChannelInitializer<SocketChannel>() {
@Override
public void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline p = ch.pipeline();
p.addLast(PcapWriteHandler.builder().sharedOutputStream(sharedOutputStream)
.writePcapGlobalHeader(writeGlobalHeaders)
.build(new ByteBufOutputStream(byteBuf)));
p.addLast(new ChannelInboundHandlerAdapter() {
private int read;
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
ByteBuf buf = (ByteBuf) msg;
read += buf.readableBytes();
ctx.writeAndFlush(buf);
if (read == payload.readableBytes()) {
serverLatch.countDown();
}
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
ctx.close();
}
});
}
});
// Start the server.
ChannelFuture serverChannelFuture = sb.bind(new InetSocketAddress("127.0.0.1", 0)).sync();
assertTrue(serverChannelFuture.isSuccess());
// configure the client
Bootstrap cb = new Bootstrap();
final CountDownLatch clientLatch = new CountDownLatch(1);
cb.group(group)
.channel(NioSocketChannel.class)
.option(ChannelOption.TCP_NODELAY, true)
.handler(new ChannelInitializer<SocketChannel>() {
@Override
public void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline p = ch.pipeline();
p.addLast(new ChannelInboundHandlerAdapter() {
private int read;
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
ByteBuf buf = (ByteBuf) msg;
read += buf.readableBytes();
buf.release();
if (read == payload.readableBytes()) {
clientLatch.countDown();
}
}
@Override
public void channelActive(ChannelHandlerContext ctx) {
ctx.writeAndFlush(payload.copy());
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
ctx.close();
}
});
}
});
InetSocketAddress serverAddress = (InetSocketAddress) serverChannelFuture.channel().localAddress();
// Start the client.
ChannelFuture clientChannelFuture = cb.connect(serverAddress).sync();
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does tcpV4() do?
tcpV4() is a function in the netty codebase, defined in handler/src/test/java/io/netty/handler/pcap/PcapWriteHandlerTest.java.
Where is tcpV4() defined?
tcpV4() is defined in handler/src/test/java/io/netty/handler/pcap/PcapWriteHandlerTest.java at line 475.
What does tcpV4() call?
tcpV4() calls 5 function(s): InetSocketAddress, channelRead, verifyTcpCapture, verifyTcpCloseCapture, verifyTcpHandshakeCapture.
What calls tcpV4()?
tcpV4() is called by 3 function(s): tcpV4NoGlobalHeaderOutputStream, tcpV4NonOutputStream, tcpV4SharedOutputStreamTest.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free