class TelnetTerminalServer {
    private final Charset charset;
    private final ServerSocket serverSocket;

    /**
     * Creates a new TelnetTerminalServer on a specific port
     * @param port Port to listen for incoming telnet connections
     * @throws IOException If there was an underlying I/O exception
     */
    public TelnetTerminalServer(int port) throws IOException {
        this(ServerSocketFactory.getDefault(), port);
    }

    /**
     * Creates a new TelnetTerminalServer on a specific port, using a certain character set
     * @param port Port to listen for incoming telnet connections
     * @param charset Character set to use
     * @throws IOException If there was an underlying I/O exception
     */
    public TelnetTerminalServer(int port, Charset charset) throws IOException {
        this(ServerSocketFactory.getDefault(), port, charset);
    }

    /**
     * Creates a new TelnetTerminalServer on a specific port through a ServerSocketFactory
     * @param port Port to listen for incoming telnet connections
     * @param serverSocketFactory ServerSocketFactory to use when creating the ServerSocket
     * @throws IOException If there was an underlying I/O exception
     */
    public TelnetTerminalServer(ServerSocketFactory serverSocketFactory, int port) throws IOException {
        this(serverSocketFactory, port, Charset.defaultCharset());
    }

    /**
     * Creates a new TelnetTerminalServer on a specific port through a ServerSocketFactory with a certain Charset
     * @param serverSocketFactory ServerSocketFactory to use when creating the ServerSocket
     * @param port Port to listen for incoming telnet connections
     * @param charset Character set to use
     * @throws IOException If there was an underlying I/O exception
     */
    public TelnetTerminalServer(ServerSocketFactory serverSocketFactory, int port, Charset charset) throws IOException {
        this.serverSocket = serverSocketFactory.createServerSocket(port);
        this.charset = charset;
    }

    /**
     * Returns the actual server socket used by this object. Can be used to tweak settings but be careful!
     * @return Underlying ServerSocket
     */
    public ServerSocket getServerSocket() {
        return serverSocket;
    }

    /**
     * Waits for the next client to connect in to our server and returns a Terminal implementation, TelnetTerminal, that
     * represents the remote terminal this client is running. The terminal can be used just like any other Terminal, but
     * keep in mind that all operations are sent over the network.
     * @return TelnetTerminal for the remote client's terminal
     * @throws IOException If there was an underlying I/O exception
     */
    public TelnetTerminal acceptConnection() throws IOException {<FILL_FUNCTION_BODY>}

    /**
     * Closes the server socket, accepting no new connection. Any call to acceptConnection() after this will fail.
     * @throws IOException If there was an underlying I/O exception
     */
    public void close() throws IOException {
        serverSocket.close();
    }
}

        Socket clientSocket = serverSocket.accept();
        clientSocket.setTcpNoDelay(true);
        return new TelnetTerminal(clientSocket, charset);
    
<no_super_class>