1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
|
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="Start" href="index.html">
<link rel="Up" href="Telnet_client.html">
<link title="Index of types" rel=Appendix href="index_types.html">
<link title="Index of exceptions" rel=Appendix href="index_exceptions.html">
<link title="Index of values" rel=Appendix href="index_values.html">
<link title="Index of class methods" rel=Appendix href="index_methods.html">
<link title="Index of classes" rel=Appendix href="index_classes.html">
<link title="Index of class types" rel=Appendix href="index_class_types.html">
<link title="Index of modules" rel=Appendix href="index_modules.html">
<link title="Ftp_client" rel="Chapter" href="Ftp_client.html">
<link title="Ftp_data_endpoint" rel="Chapter" href="Ftp_data_endpoint.html">
<link title="Http_client" rel="Chapter" href="Http_client.html">
<link title="Http_client_mt" rel="Chapter" href="Http_client_mt.html">
<link title="Telnet_client" rel="Chapter" href="Telnet_client.html"><title>The Netclient Manual : Telnet_client.telnet_session</title>
</head>
<body>
<div class="navbar"> <a href="Telnet_client.html">Up</a>
</div>
<center><h1>Class <a href="type_Telnet_client.telnet_session.html">Telnet_client.telnet_session</a></h1></center>
<br>
<pre><span class="keyword">class</span> <a name="TYPEtelnet_session"></a>telnet_session : <code class="type"></code><code class="code">object</code> <a href="Telnet_client.telnet_session.html">..</a> <code class="code">end</code></pre>A telnet session<br>
<hr width="100%">
<a name="2_Overwiew"></a>
<h2>Overwiew</h2>
<p>
The <code class="code">telnet_session</code> 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 <code class="code">Telnet_eof</code>
onto the output queue.
Once the EOF marker has been received, a <code class="code">Telnet_eof</code> is appended to
the input queue, and the connection is closed (completely). The
session object detaches from the event system automatically in this
case.
<p>
<b>Hints</b>
<p>
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.
<p>
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 <code class="code">update</code> method.
<p>
If you want option negotiation, it is the simplest way to use
the special option negotiation methods. Configure the options
as you want (invoking <code class="code">enable</code>, <code class="code">disable</code> etc), but do not forget
to modify the way input is processed. Every <code class="code">Telnet_will</code>, <code class="code">_wont</code>,
<code class="code">_do</code>, and <code class="code">_dont</code> command must be passed to <code class="code">process_option_command</code>.<pre><span class="keyword">method</span> <a name="METHODset_connection"></a>set_connection : <code class="type"><a href="Telnet_client.html#TYPEtelnet_connector">telnet_connector</a> -> unit</code></pre><div class="info">
Sets the host name and the port of the remote server to contact.<br>
</div>
<pre><span class="keyword">method</span> <a name="METHODset_event_system"></a>set_event_system : <code class="type">Unixqueue.event_system -> unit</code></pre><div class="info">
Sets the event system to use. By default, a private event system
is used.<br>
</div>
<pre><span class="keyword">method</span> <a name="METHODset_callback"></a>set_callback : <code class="type">(bool -> unit) -> unit</code></pre><div class="info">
Sets the callback function. This function is called after new
commands have been put onto the input queue.
The argument passed to the callback function indicates whether
a 'Synch' sequence was received from the remote side or not.
<p>
<b>Note Synch:</b> If the client sees a data mark command it will assume
that it is actually a Synch sequence. The client automatically
discards any <code class="code">Telnet_data</code> commands from the input queue (but not
<code class="code">Telnet_data</code>s inside subnegotiations). The data mark command
itself remains on the queue.<br>
</div>
<pre><span class="keyword">method</span> <a name="METHODset_exception_handler"></a>set_exception_handler : <code class="type">(exn -> unit) -> unit</code></pre><div class="info">
Sets the exception handler. Every known error condition is
caught and passed to the exception handler.
The exception handler can do whatever it wants to do. If it
raises again an exception, the new exception is always propagated
up to the caller (whoever this is). Often the caller is the
event system scheduler (i.e. <code class="code">Unixqueue.run</code>); see the documention
there.
<p>
If you do not set the exception handler, a default handler is
active. It first resets the session (see method <code class="code">reset</code>), and
then wraps the exception into the <code class="code">Telnet_protocol</code> exception,
and raises this exception again.<br>
</div>
<pre><span class="keyword">method</span> <a name="METHODoutput_queue"></a>output_queue : <code class="type"><a href="Telnet_client.html#TYPEtelnet_command">telnet_command</a> Queue.t</code></pre><div class="info">
The queue of commands to send to the remote side. If you add new
commands to this queue, do not forget to invoke the <code class="code">update</code>
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.<br>
</div>
<pre><span class="keyword">method</span> <a name="METHODinput_queue"></a>input_queue : <code class="type"><a href="Telnet_client.html#TYPEtelnet_command">telnet_command</a> Queue.t</code></pre><div class="info">
The queue of commands received from the remote side. This class
only adds commands to the queue (and invokes the callback
function). The user of this class is responsible for removing
commands from the queue which have been processed.<br>
</div>
<pre><span class="keyword">method</span> <a name="METHODget_options"></a>get_options : <code class="type"><a href="Telnet_client.html#TYPEtelnet_options">telnet_options</a></code></pre><div class="info">
Get the configuration options.<br>
</div>
<pre><span class="keyword">method</span> <a name="METHODset_options"></a>set_options : <code class="type"><a href="Telnet_client.html#TYPEtelnet_options">telnet_options</a> -> unit</code></pre><div class="info">
Set the configuration options.<br>
</div>
<pre><span class="keyword">method</span> <a name="METHODreset"></a>reset : <code class="type">unit -> unit</code></pre><div class="info">
Closes the connection immediately and empties all queues.
All negotiated options are reset, too.<br>
</div>
<a name="2_Telnetoptions"></a>
<h2>Telnet options</h2>
<p>
The following methods deal with Telnet protocol options. These
are negotiated between local and remote side by the Will, Won't,
Do and Don't commands.
<p>
The "local" options describe the modification of the behaviour
of the local side; the "remote" options describe the modifications
of the remote side. Both set of options are independent.
This object may track the set of accepted and rejected options
if the following methods are used; but this works only if
the <code class="code">Telnet_will</code>, <code class="code">_wont</code>, <code class="code">_do</code>, and <code class="code">_dont</code> commands received from
the remote side are processed by <code class="code">process_option_command</code>. So
you need to invoke this method for the mentioned commands in
your command interpretation loop.
<p>
The idea is: If you <b>enable</b> an option, it is possible to
switch it on. If the remote side requests the option to be enabled,
the request will be acknowledged. If the remote side does not
request the option, it remains off.
<p>
You can also actively demand an option (<code class="code">offer_local_option</code>,
<code class="code">request_remote_option</code>); this is of course only possible if
the option is already enabled. In this case the client tries
actively to switch it on.
<p>
You can also <b>disable</b> an option. If the option is on, the
client actively rejects the option; following the Telnet protocol
this is always possible (rejections cannot be rejected).
<p>
The <code class="code">reset</code> methods are somewhat dangerous. They simply reset
the internal state of the client, but do not negotiate. This
possibility was added to allow the Timing Mark option to send
again timing marks even if the previous timing marks have
already been accepted. After <code class="code">reset</code>, the client thinks the
option was never negotiated; but nothing is done to tell
the remote side about this.
<p>
<code class="code">option_negotiation_is_over</code>: true if no option negotiation is
pending (i.e. nothing has still to be acknowledged).<pre><span class="keyword">method</span> <a name="METHODenable_local_option"></a>enable_local_option : <code class="type"><a href="Telnet_client.html#TYPEtelnet_negotiated_option">telnet_negotiated_option</a> -> unit</code></pre><pre><span class="keyword">method</span> <a name="METHODenable_remote_option"></a>enable_remote_option : <code class="type"><a href="Telnet_client.html#TYPEtelnet_negotiated_option">telnet_negotiated_option</a> -> unit</code></pre><pre><span class="keyword">method</span> <a name="METHODdisable_local_option"></a>disable_local_option : <code class="type"><a href="Telnet_client.html#TYPEtelnet_negotiated_option">telnet_negotiated_option</a> -> unit</code></pre><pre><span class="keyword">method</span> <a name="METHODdisable_remote_option"></a>disable_remote_option : <code class="type"><a href="Telnet_client.html#TYPEtelnet_negotiated_option">telnet_negotiated_option</a> -> unit</code></pre><pre><span class="keyword">method</span> <a name="METHODoffer_local_option"></a>offer_local_option : <code class="type"><a href="Telnet_client.html#TYPEtelnet_negotiated_option">telnet_negotiated_option</a> -> unit</code></pre><pre><span class="keyword">method</span> <a name="METHODrequest_remote_option"></a>request_remote_option : <code class="type"><a href="Telnet_client.html#TYPEtelnet_negotiated_option">telnet_negotiated_option</a> -> unit</code></pre><pre><span class="keyword">method</span> <a name="METHODreset_local_option"></a>reset_local_option : <code class="type"><a href="Telnet_client.html#TYPEtelnet_negotiated_option">telnet_negotiated_option</a> -> unit</code></pre><pre><span class="keyword">method</span> <a name="METHODreset_remote_option"></a>reset_remote_option : <code class="type"><a href="Telnet_client.html#TYPEtelnet_negotiated_option">telnet_negotiated_option</a> -> unit</code></pre><pre><span class="keyword">method</span> <a name="METHODget_local_option"></a>get_local_option : <code class="type"><a href="Telnet_client.html#TYPEtelnet_negotiated_option">telnet_negotiated_option</a> -> <a href="Telnet_client.html#TYPEtelnet_option_state">telnet_option_state</a></code></pre><pre><span class="keyword">method</span> <a name="METHODget_remote_option"></a>get_remote_option : <code class="type"><a href="Telnet_client.html#TYPEtelnet_negotiated_option">telnet_negotiated_option</a> -> <a href="Telnet_client.html#TYPEtelnet_option_state">telnet_option_state</a></code></pre><pre><span class="keyword">method</span> <a name="METHODoption_negotiation_is_over"></a>option_negotiation_is_over : <code class="type">bool</code></pre><pre><span class="keyword">method</span> <a name="METHODprocess_option_command"></a>process_option_command : <code class="type"><a href="Telnet_client.html#TYPEtelnet_command">telnet_command</a> -> unit</code></pre><pre><span class="keyword">method</span> <a name="METHODfetch_subnegotiation"></a>fetch_subnegotiation : <code class="type">string option</code></pre><div class="info">
This method should be called as follows:
If you find a <code class="code">Telnet_sb</code> at the beginning of the input queue,
remove this command <code class="code">Queue.take</code>, and invoke <code class="code">fetch_subnegotiation</code>.
This method scans the queue and looks for the associated
<code class="code">Telnet_se</code> command. If it does not find it, <code class="code">None</code> is returned.
If <code class="code">Telnet_se</code> is found, the parameter enclosed by the two commands
is returned as <code class="code">Some s</code> where <code class="code">s</code> is the parameter string. Furthermore,
in the latter case the data items and the closing <code class="code">Telnet_se</code> are
removed from the queue.<br>
</div>
<a name="2_Runningthesession"></a>
<h2>Running the session</h2><pre><span class="keyword">method</span> <a name="METHODattach"></a>attach : <code class="type">unit -> unit</code></pre><div class="info">
Attach to the event system. After being attached, the client
is ready to work.<br>
</div>
<pre><span class="keyword">method</span> <a name="METHODrun"></a>run : <code class="type">unit -> unit</code></pre><div class="info">
Run the event system<br>
</div>
<pre><span class="keyword">method</span> <a name="METHODupdate"></a>update : <code class="type">unit -> unit</code></pre><div class="info">
If there are commands in the output queue, the event system is
signaled that this client wants to do network I/O.<br>
</div>
<pre><span class="keyword">method</span> <a name="METHODsend_synch"></a>send_synch : <code class="type"><a href="Telnet_client.html#TYPEtelnet_command">telnet_command</a> list -> unit</code></pre><div class="info">
At the next output oppurtunity, a Synch sequence is sent to
the remote peer. This means that the passed commands, extended
by an additional Data Mark command, are sent to the peer as
urgent data.
<p>
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.<br>
</div>
</body></html>
|