module Telnet_client: sig
.. end
Telnet client
This is a Telnet client providing the basic Telnet services. It
supports sending and receiving data (asynchronously), and the
negotiation of Telnet options, but it does not implement any option.
exception Telnet_protocol of exn
Wrapper for exceptions that already passed the exception handler.
type
telnet_command =
| |
Telnet_data of string |
| |
Telnet_nop |
| |
Telnet_dm |
| |
Telnet_brk |
| |
Telnet_ip |
| |
Telnet_ao |
| |
Telnet_ayt |
| |
Telnet_ec |
| |
Telnet_el |
| |
Telnet_ga |
| |
Telnet_sb of char |
| |
Telnet_se |
| |
Telnet_will of char |
| |
Telnet_wont of char |
| |
Telnet_do of char |
| |
Telnet_dont of char |
| |
Telnet_unknown of char |
| |
Telnet_eof |
| |
Telnet_timeout |
A telnet_command
is the interpretation of the octets in a Telnet
session, i.e. it is one level above the octet stream. See RFC 854
for an explanation what the commands mean. Telnet_data
represents
the data chunks between the commands. Note that you do not need
to double octets having value 255; this is done automatically.
Telnet_unknown
represents any command not covered by RFC 854, for
example the End-of-record-mark (introduced in RFC 885) would be
Telnet_unknown '\239'
. Telnet_eof
represents the end of the octet
stream, useable in both directions. Telnet_timeout
is added to the
input queue if I/O has not been happened for the configured period
of time.
type
telnet_options = {
|
connection_timeout : float ; |
|
verbose_connection : bool ; |
|
verbose_input : bool ; |
|
verbose_output : bool ; |
}
telnet_options
: modifies the behaviour of the client. Do not mix these
options up with the options negotiated with the remote side.
connection_timeout
: After this period of time (in seconds) a
Telnet_timeout
pseudo-command is added to
the input queue, and the connection is
aborted.
verbose_connection
: Enables printing of connection events to stderr.
verbose_input
: Enables printing of input events to stderr.
verbose_output
: Enables printing of output events to stderr.
type
telnet_negotiated_option =
| |
Telnet_binary |
| |
Telnet_echo |
| |
Telnet_suppress_GA |
| |
Telnet_status |
| |
Telnet_timing_mark |
| |
Telnet_ext_opt_list |
| |
Telnet_end_of_rec |
| |
Telnet_window_size |
| |
Telnet_term_speed |
| |
Telnet_term_type |
| |
Telnet_X_display |
| |
Telnet_linemode |
| |
Telnet_flow_ctrl |
| |
Telnet_auth |
| |
Telnet_new_environ |
| |
Telnet_option of int |
telnet_negotiated_option
: names for the most common options, and
the generic name Telnet_option
for other options.
type
telnet_option_state =
| |
Not_negotiated |
| |
Accepted |
| |
Rejected |
An option has one of three states:
Not_negotiated
: There was no negotiation about the option. This means
that the option is turned off (but this client is allowed to reject
it explicitly)
Accepted
: Both sides have accepted the option.
Rejected
: One side has rejected the option. This also means that the
option is off, but the client refuses to send further acknoledgements
that the option is off (to avoid endless negotiation loops).
val char_of_option : telnet_negotiated_option -> char
Converts the option name to the character representing it on the
octet-stream level.
val option_of_char : char -> telnet_negotiated_option
Converts a character representing an option to the internal option
name.
type
telnet_connector =
| |
Telnet_connect of (string * int) |
| |
Telnet_socket of Unix.file_descr |
Connectors:
Telnet_connect(host,port)
: The client connects to this port.
Telnet_socket s
: The client uses an already connected socket.
Why
Telnet_socket
? Telnet is a symmetrical protocol; client and servers
implement the same protocol features (the only difference is the
environment: a client is typically connected with a real terminal; a server
is connected with a pseudo terminal). This simply means that this
implementation of a client can also be used as a server implementation.
You need only to add code which accepts new connections and which passes
these connections over to a
telnet_session
object via
Telnet_socket
.
class telnet_session :
object
.. end
A telnet session