diff --git a/src/main/java/at/downardo/j3270Server/Telnet.java b/src/main/java/at/downardo/j3270Server/Telnet.java index a76d7b5..58d9d14 100644 --- a/src/main/java/at/downardo/j3270Server/Telnet.java +++ b/src/main/java/at/downardo/j3270Server/Telnet.java @@ -12,6 +12,22 @@ import java.io.IOException; public class Telnet { + + + private static final byte BINARY = (byte)0x00; + private static final byte SEND = (byte)0x01; + private static final byte SE = (byte)0xf0; + private static final byte SB = (byte)0xfa; + private static final byte WILL = (byte)0xfb; + private static final byte WONT = (byte)0xfc; + private static final byte DO = (byte)0xfd; + private static final byte DONT = (byte)0xfe; + private static final byte IAC = (byte)0xff; + private static final byte TERMINALTYPE = (byte)0x18; + private static final byte EOR = (byte)0x19; + + + /** * NegotiateTelnet will naively (e.g. not checking client responses) * negotiate the options necessary for tn3270 on a new telnet connection @@ -20,34 +36,34 @@ public class Telnet { */ public static void NegotiateTelnet(BufferedOutputStream out, BufferedInputStream in) { byte[] _trash = new byte[255]; - byte[] _t = {(byte) 0xff, (byte) 0xfd, 0x18}; + byte[] _t = {IAC,DO,TERMINALTYPE}; try { out.write(_t); out.flush(); in.read(_trash); - byte[] _2t = {(byte) 0xff, (byte) 0xfd, 0x18, 0x01, (byte) 0xff, (byte) 0xf0}; + byte[] _2t = {IAC,SB,TERMINALTYPE,SEND,IAC,SE}; out.write(_2t); out.flush(); in.read(_trash); - byte[] _3t = {(byte) 0xff, (byte) 0xfd, 0x19}; + byte[] _3t = {IAC,DO,EOR}; out.write(_3t); out.flush(); in.read(_trash); - byte[] _4t = {(byte) 0xff, (byte) 0xfd, 0x00}; + byte[] _4t = {IAC,DO,BINARY}; out.write(_4t); out.flush(); in.read(_trash); - byte[] _5t = {(byte) 0xff, (byte) 0xfd, 0x19, (byte) 0xff, (byte) 0xfb, 0x00}; + byte[] _5t = {IAC,WILL,EOR,IAC,WILL,BINARY}; out.write(_5t); out.flush();