14 #define RAW_MAX_BACKLOG 4096
16 static Socket s = NULL;
17 static int raw_bufsize;
19 static void raw_size(void);
21 static void c_write(char *buf, int len)
23 int backlog = from_backend(0, buf, len);
24 sk_set_frozen(s, backlog > RAW_MAX_BACKLOG);
27 static int raw_closing(Plug plug, char *error_msg, int error_code,
35 /* A socket error has occurred. */
36 connection_fatal(error_msg);
37 } /* Otherwise, the remote side closed the connection normally. */
41 static int raw_receive(Plug plug, int urgent, char *data, int len)
47 static void raw_sent(Plug plug, int bufsize)
49 raw_bufsize = bufsize;
53 * Called to set up the raw connection.
55 * Returns an error message, or NULL on success.
57 * Also places the canonical host name into `realhost'. It must be
58 * freed by the caller.
60 static char *raw_init(char *host, int port, char **realhost, int nodelay)
62 static struct plug_function_table fn_table = {
66 }, *fn_table_ptr = &fn_table;
76 sprintf(buf, "Looking up host \"%.170s\"", host);
79 addr = sk_namelookup(host, realhost);
80 if ((err = sk_addr_error(addr)))
84 port = 23; /* default telnet port */
90 char buf[200], addrbuf[100];
91 sk_getaddr(addr, addrbuf, 100);
92 sprintf(buf, "Connecting to %.100s port %d", addrbuf, port);
95 s = sk_new(addr, port, 0, 1, nodelay, &fn_table_ptr);
96 if ((err = sk_socket_error(s)))
105 * Called to send data down the raw connection.
107 static int raw_send(char *buf, int len)
112 raw_bufsize = sk_write(s, buf, len);
118 * Called to query the current socket sendability status.
120 static int raw_sendbuffer(void)
126 * Called to set the size of the window
128 static void raw_size(void)
135 * Send raw special codes.
137 static void raw_special(Telnet_Special code)
143 static Socket raw_socket(void)
148 static int raw_sendok(void)
153 static void raw_unthrottle(int backlog)
155 sk_set_frozen(s, backlog > RAW_MAX_BACKLOG);
158 static int raw_ldisc(int option)
160 if (option == LD_EDIT || option == LD_ECHO)
165 static int raw_exitcode(void)
167 /* Exit codes are a meaningless concept in the Raw protocol */
171 Backend raw_backend = {