class telnet_session :object
..end
The telnet_session
object has two queues, one for arriving data,
one for data to send.
Once the session object is attached to an event system, it connects
to the remote peer, and processes the queues. Input is appended to
the input queue; output found on the output queue is sent to the
other side.
If input arrives, a callback function is invoked.
You may close the output side of the socket by putting Telnet_eof
onto the output queue.
Once the EOF marker has been received, a Telnet_eof
is appended to
the input queue, and the connection is closed (completely). The
session object detaches from the event system automatically in this
case.
Hints
Set an input handler as callback function in the session object. The input handler is called when new input data have been arrived. It should inspect the input queue, process the queue as much as possible, and it should remove the processed items from the queue. While processing, it may add new items to the output queue.
If you are not within the callback function and add items to the
output queue, the session object will not detect that there are
new items to send - unless you invoke the update
method.
If you want option negotiation, it is the simplest way to use
the special option negotiation methods. Configure the options
as you want (invoking enable
, disable
etc), but do not forget
to modify the way input is processed. Every Telnet_will
, _wont
,
_do
, and _dont
command must be passed to process_option_command
.
method set_connection : telnet_connector -> unit
method set_event_system : Unixqueue.event_system -> unit
method set_callback : (bool -> unit) -> unit
Note Synch: If the client sees a data mark command it will assume
that it is actually a Synch sequence. The client automatically
discards any Telnet_data
commands from the input queue (but not
Telnet_data
s inside subnegotiations). The data mark command
itself remains on the queue.
method set_exception_handler : (exn -> unit) -> unit
Unixqueue.run
); see the documention
there.
If you do not set the exception handler, a default handler is
active. It first resets the session (see method reset
), and
then wraps the exception into the Telnet_protocol
exception,
and raises this exception again.
method output_queue : telnet_command Queue.t
update
method which indicates to the event system that new data to
send is available.
After commands have been sent, they are removed from the queue.method input_queue : telnet_command Queue.t
method get_options : telnet_options
method set_options : telnet_options -> unit
method reset : unit -> unit
method enable_local_option : telnet_negotiated_option -> unit
method enable_remote_option : telnet_negotiated_option -> unit
method disable_local_option : telnet_negotiated_option -> unit
method disable_remote_option : telnet_negotiated_option -> unit
method offer_local_option : telnet_negotiated_option -> unit
method request_remote_option : telnet_negotiated_option -> unit
method reset_local_option : telnet_negotiated_option -> unit
method reset_remote_option : telnet_negotiated_option -> unit
method get_local_option : telnet_negotiated_option ->
telnet_option_state
method get_remote_option : telnet_negotiated_option ->
telnet_option_state
method option_negotiation_is_over : bool
method process_option_command : telnet_command -> unit
method fetch_subnegotiation : string option
Telnet_sb
at the beginning of the input queue,
remove this command Queue.take
, and invoke fetch_subnegotiation
.
This method scans the queue and looks for the associated
Telnet_se
command. If it does not find it, None
is returned.
If Telnet_se
is found, the parameter enclosed by the two commands
is returned as Some s
where s
is the parameter string. Furthermore,
in the latter case the data items and the closing Telnet_se
are
removed from the queue.method attach : unit -> unit
method run : unit -> unit
method update : unit -> unit
method send_synch : telnet_command list -> unit
Sending a Synch sequence has higher priority than the output
queue; processing of the output queue is deferred until the
Synch sequence has been completely sent.
method expect_input : bool -> unit
true
by default.method start_tls : (module Netsys_crypto_types.TLS_CONFIG) -> peer_name:string option -> unit
Switching to TLS can be done at any time, but should be done at a
moment when the other side of the connection expects it. If
start_tls
is invoked before attach
, TLS is enabled at the
very beginning of the TELNET connection.
The arguments are the TLS configuration, and the peer name for
validation (pass the host name here).
method tls_session_props : Nettls_support.tls_session_props option
method tls_session_data : string option