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. */
37 connection_fatal("%s", error_msg);
38 } /* Otherwise, the remote side closed the connection normally. */
42 static int raw_receive(Plug plug, int urgent, char *data, int len)
48 static void raw_sent(Plug plug, int bufsize)
50 raw_bufsize = bufsize;
54 * Called to set up the raw connection.
56 * Returns an error message, or NULL on success.
58 * Also places the canonical host name into `realhost'. It must be
59 * freed by the caller.
61 static char *raw_init(char *host, int port, char **realhost, int nodelay)
63 static struct plug_function_table fn_table = {
67 }, *fn_table_ptr = &fn_table;
77 sprintf(buf, "Looking up host \"%.170s\"", host);
80 addr = sk_namelookup(host, realhost);
81 if ((err = sk_addr_error(addr)))
85 port = 23; /* default telnet port */
91 char buf[200], addrbuf[100];
92 sk_getaddr(addr, addrbuf, 100);
93 sprintf(buf, "Connecting to %.100s port %d", addrbuf, port);
96 s = new_connection(addr, *realhost, port, 0, 1, nodelay, &fn_table_ptr);
97 if ((err = sk_socket_error(s)))
106 * Called to send data down the raw connection.
108 static int raw_send(char *buf, int len)
113 raw_bufsize = sk_write(s, buf, len);
119 * Called to query the current socket sendability status.
121 static int raw_sendbuffer(void)
127 * Called to set the size of the window
129 static void raw_size(void)
136 * Send raw special codes.
138 static void raw_special(Telnet_Special code)
144 static Socket raw_socket(void)
149 static int raw_sendok(void)
154 static void raw_unthrottle(int backlog)
156 sk_set_frozen(s, backlog > RAW_MAX_BACKLOG);
159 static int raw_ldisc(int option)
161 if (option == LD_EDIT || option == LD_ECHO)
166 static int raw_exitcode(void)
168 /* Exit codes are a meaningless concept in the Raw protocol */
172 Backend raw_backend = {