Home / Class/ TelnetClient Class — netty Architecture

TelnetClient Class — netty Architecture

Architecture documentation for the TelnetClient class in TelnetClient.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  53e46bcf_f135_1fe4_57dd_8377a83c1c38["TelnetClient"]
  a419d3c7_4770_a674_3952_13e1249753db["TelnetClient.java"]
  53e46bcf_f135_1fe4_57dd_8377a83c1c38 -->|defined in| a419d3c7_4770_a674_3952_13e1249753db
  2baed923_bc22_178c_fd94_7a0923366fca["main()"]
  53e46bcf_f135_1fe4_57dd_8377a83c1c38 -->|method| 2baed923_bc22_178c_fd94_7a0923366fca

Relationship Graph

Source Code

example/src/main/java/io/netty/example/telnet/TelnetClient.java lines 34–82

public final class TelnetClient {

    static final boolean SSL = System.getProperty("ssl") != null;
    static final String HOST = System.getProperty("host", "127.0.0.1");
    static final int PORT = Integer.parseInt(System.getProperty("port", SSL? "8992" : "8023"));

    public static void main(String[] args) throws Exception {
        // Configure SSL.
        final SslContext sslCtx = ServerUtil.buildSslContext();

        EventLoopGroup group = new MultiThreadIoEventLoopGroup(NioIoHandler.newFactory());
        try {
            Bootstrap b = new Bootstrap();
            b.group(group)
             .channel(NioSocketChannel.class)
             .handler(new TelnetClientInitializer(sslCtx));

            // Start the connection attempt.
            Channel ch = b.connect(HOST, PORT).sync().channel();

            // Read commands from the stdin.
            ChannelFuture lastWriteFuture = null;
            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
            for (;;) {
                String line = in.readLine();
                if (line == null) {
                    break;
                }

                // Sends the received line to the server.
                lastWriteFuture = ch.writeAndFlush(line + "\r\n");

                // If user typed the 'bye' command, wait until the server closes
                // the connection.
                if ("bye".equals(line.toLowerCase())) {
                    ch.closeFuture().sync();
                    break;
                }
            }

            // Wait until all messages are flushed before closing the channel.
            if (lastWriteFuture != null) {
                lastWriteFuture.sync();
            }
        } finally {
            group.shutdownGracefully();
        }
    }
}

Frequently Asked Questions

What is the TelnetClient class?
TelnetClient is a class in the netty codebase, defined in example/src/main/java/io/netty/example/telnet/TelnetClient.java.
Where is TelnetClient defined?
TelnetClient is defined in example/src/main/java/io/netty/example/telnet/TelnetClient.java at line 34.

Analyze Your Own Codebase

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

Try Supermodel Free