Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: e6dc0908fb9a0025776d604056bb07c0a9088538 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*******************************************************************************
 * Copyright (c) 2010, 2011 SAP AG
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 * 
 * Contributors:
 *     Lazar Kirchev, SAP AG - initial API and implementation  
 *******************************************************************************/

package org.eclipse.equinox.console.telnet;

import org.eclipse.equinox.console.common.ConsoleOutputStream;

import java.io.IOException;
import java.io.OutputStream;

/**
 * This class adds to the output stream wrapper initial negotiation of telnet communication.
 */
public class TelnetOutputStream extends ConsoleOutputStream {
	
	static final byte[] autoMessage = new byte[]{(byte) 255, (byte) 251, (byte) 1, // IAC WILL ECHO
												 (byte) 255, (byte) 251, (byte) 3, // IAC WILL SUPPRESS GO_AHEAD
												 (byte) 255, (byte) 253, (byte) 31, // IAC DO NAWS
												 (byte) 255, (byte) 253, (byte) 24}; // IAC DO TTYPE
	
	public TelnetOutputStream(OutputStream out) {
		super(out);
	}

	/**
	 * Sends the options which a server wants to negotiate with a telnet client.
	 */
	public synchronized void autoSend() throws IOException {
		write(autoMessage);
		flush();
	}

}

Back to the top