01: package gnu.jemacs.buffer;
02:
03: import kawa.*;
04: import gnu.mapping.*;
05: import java.io.*;
06:
07: public class TelnetMode extends ProcessMode {
08: public TelnetMode(Buffer buffer, String host) {
09: this (buffer, host, 23);
10: }
11:
12: public TelnetMode(Buffer buffer, String host, int port) {
13: this .buffer = buffer;
14: processMark = new Marker(buffer.pointMarker);
15:
16: Telnet telnet;
17: try {
18: java.net.Socket socket = new java.net.Socket(host, port);
19: telnet = new Telnet(socket, false);
20: telnet.request(Telnet.DO, Telnet.SUPPRESS_GO_AHEAD);
21: telnet.request(Telnet.WILL, Telnet.SUPPRESS_GO_AHEAD);
22: telnet.request(Telnet.DO, Telnet.ECHO);
23: } catch (Exception ex) {
24: throw new WrappedException(
25: "telnet - creating socket failed", ex);
26: }
27: toInferior = new OutputStreamWriter(telnet.getOutputStream());
28: Thread t = new InputStreamHandler(telnet.getInputStream(), this );
29: t.setPriority(Thread.currentThread().getPriority() + 1);
30: t.start();
31: }
32:
33: //protected static final int ENTER_CODE = 1;
34: //static Procedure enter = new ModuleMethod(this, ENTER_CODE, "enter", 0);
35:
36: public static void telnetMode(Buffer buffer, String host, int port) {
37: buffer.modes = new TelnetMode(buffer, host, port);
38: }
39:
40: /*
41: public Object apply0(ModuleMethod proc)
42: {
43: switch (proc.selector)
44: {
45: case ENTER_CODE:
46: enter();
47: return Values.empty;
48: }
49: return super.apply0(proc);
50: }
51: */
52:
53: }
|