Qore TelnetClient Module Reference 1.7
Loading...
Searching...
No Matches
TelnetClient.qm.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
4/* TelnetClient.qm Copyright 2012 - 2023 Qore Technologies s.r.o.
5
6 Original Author: Pavol Potancok
7
8 Permission is hereby granted, free of charge, to any person obtaining a
9 copy of this software and associated documentation files (the "Software"),
10 to deal in the Software without restriction, including without limitation
11 the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 and/or sell copies of the Software, and to permit persons to whom the
13 Software is furnished to do so, subject to the following conditions:
14
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 DEALINGS IN THE SOFTWARE.
25*/
26
27// minimum required Qore version
28
29// assume local var scope, do not use "$" for vars, members, and method calls
30
31
32
95namespace TelnetClient {
99// default telnet port
100const DefaultTelnetPort = 23;
101
102// default connection timeout
103const DefaultConnTimeout = 15s;
104
105// default poll timeout
106const DefaultTimeout = 100ms;
107
108// default terminal type
109const DefaultTerminalType = "xterm";
110
111// default terminal speed
112const DefaultTerminalSpeed = 38400;
114
118const IAC = 255; #!< IAC
119const DONT = 254; #!< DONT
120const DO = 253; #!< DO
121const WONT = 252; #!< WONT
122const WILL = 251; #!< WILL
123const SE = 240; #!< Subnegotiation End
124const NOP = 241; #!< No Operation
125const DM = 242; #!< Data Mark
126const BRK = 243; #!< Break
127const IP = 244; #!< Interrupt process
128const AO = 245; #!< Abort output
129const AYT = 246; #!< Are You There
130const EC = 247; #!< Erase Character
131const EL = 248; #!< Erase Line
132const GA = 249; #!< Go Ahead
133const SB = 250; #!< Subnegotiation Begin
134
136const CmdMap = ...;
137
139
140const SUPDUP_OPT = 21; # SUPDUP_OPT display protocol
141
145const TOPT_BIN = 0; #!< BinaryTransmission
146const TOPT_ECHO = 1; #!< Echo|Is|Send
147const TOPT_RECN = 2; #!< Reconnection
148const TOPT_SUPP = 3; #!< SuppressGoAhead
149const TOPT_APRX = 4; #!< ApproxMessageSizeNegotiation
150const TOPT_STAT = 5; #!< Status
151const TOPT_TIM = 6; #!< TimingMark
152const TOPT_REM = 7; #!< RemoteControlledTransandEcho
153const TOPT_OLW = 8; #!< OutputLineWidth
154const TOPT_OPS = 9; #!< OutputPageSize
155const TOPT_OCRD = 10; #!< OutputCarriage-ReturnDisposition
156const TOPT_OHT = 11; #!< OutputHorizontalTabstops
157const TOPT_OHTD = 12; #!< OutputHorizontalTabDisposition
158const TOPT_OFD = 13; #!< OutputFormfeedDisposition
159const TOPT_OVT = 14; #!< OutputVerticalTabstops
160const TOPT_OVTD = 15; #!< OutputVerticalTabDisposition
161const TOPT_OLD = 16; #!< OutputLinefeedDisposition
162const TOPT_EXT = 17; #!< ExtendedASCII
163const TOPT_LOGO = 18; #!< Logout
164const TOPT_BYTE = 19; #!< ByteMacro
165const TOPT_DATA = 20; #!< DataEntryTerminal
166const TOPT_SUP = 21; #!< SUPDUP
167const TOPT_SUPO = 22; #!< SUPDUPOutput
168const TOPT_SNDL = 23; #!< SendLocation
169const TOPT_TERM = 24; #!< TerminalType
170const TOPT_EOR = 25; #!< EndofRecord
171const TOPT_TACACS = 26; #!< TACACSUserIdent
172const TOPT_OM = 27; #!< OutputMarking
173const TOPT_TLN = 28; #!< TerminalLocationNumber
174const TOPT_3270 = 29; #!< Telnet3270Regime
175const TOPT_X3 = 30; #!< X.3PAD
176const TOPT_NAWS = 31; #!< NegotiateAboutWindowSize
177const TOPT_TS = 32; #!< TerminalSpeed
178const TOPT_RFC = 33; #!< RemoteFlowControl
179const TOPT_LINE = 34; #!< Linemode
180const TOPT_XDL = 35; #!< XDisplayLocation
181const TOPT_ENVIR = 36; #!< TelnetEnvironmentOption
182const TOPT_AUTH = 37; #!< TelnetAuthenticationOption
183const TOPT_ENVIR_NEW = 39; #!< TelnetNewEnvironmentOption
184const TOPT_TN3270 = 40; #!< TN3270Enhancements
185const TOPT_X_AUTH = 41; #!< TelnetXAUTH
186const TOPT_CHARSET = 42; #!< TelnetCHARSET
187const TOPT_RSP = 43; #!< TelnetRemoteSerialPort
188const TOPT_COMPORT = 44; #!< TelnetComPortControl
189const TOPT_SLE = 45; #!< TelnetSuppressLocalEcho
190const TOPT_STARTTLS = 46; #!< TelnetStartTLS
191const TOPT_KERMIT = 47; #!< TelnetKERMIT
192const TOPT_SEND_URL = 48; #!< Send-URL
193const TOPT_EXTOP = 255; #!< Extended-Options-List
194
196const OptMap = ...;
197
199
201
205
206public:
208protected:
209 // the connection string
210 string connect;
211
212 // the socket for all communication with the server
213 Socket conn();
214
215 // to manage contention on the Socket
216 Mutex m();
217
218 // login user
219 *string user;
220
221 // logging closures
222 *code log_info;
223 *code log_debug;
224
225 // hash of features the telnet server has asked for
226 hash fh;
227
228public:
230
231 // no public members
232
233
235
240 constructor(string host, softint port, *code log, *code dbglog);
241
242
244
256 constructor(string connect, *code log, *code dbglog);
257
258
261
262
264protected:
265 log(string msg);
266public:
267
268
270protected:
271 logDbg(string msg);
272public:
273
274
276
279 connect(timeout timeout = DefaultConnTimeout);
280
281
284
285
287
291 setUser(*string n_user);
292
293
295 *string getUser();
296
297
299
302
303
305
317 sendData(softlist arr);
318
319
321
329 sendTextData(string str);
330
331
333
339 *string getAvailableData(timeout t = DefaultTimeout);
340
341
343
351 bool hasFeature(int fc);
352
353
355
358
359
361
363protected:
364 *string getDisplay();
365public:
366
367
369
371protected:
373public:
374
375
377
379protected:
381public:
382
383
385
387protected:
389public:
390
391
393
400protected:
402public:
403
404
406
416
417
419
449 nothing setWarningQueue(int warning_ms, int warning_bs, Queue queue, any arg, timeout min_ms = 1s);
450
451
453
471 hash<auto> getUsageInfo();
472
473
475
485
486
488
504 setEventQueue(Qore::Thread::Queue queue, auto arg, *bool with_data);
505
506
508
518
519
521
523 string getTarget();
524
525
527 // don't override this method, fix/enhance it with a patch to the module
528protected:
529 final disconnectIntern();
530public:
531
532
533protected:
534 checkConnIntern();
535public:
536
537
538 // don't override this method, fix/enhance it with a patch to the module
539protected:
540 final sendDataIntern(softlist arr, bool double_aic = False);
541public:
542
543
544protected:
545 sendTextDataIntern(string str);
546public:
547
548
549 // don't override this method, fix/enhance it with a patch to the module
550protected:
551 final *string getAvailableDataIntern(timeout t = DefaultTimeout);
552public:
553
554
555 // don't override this method, fix/enhance it with a patch to the module
556protected:
557 final updateWindowSizeIntern(hash wh);
558public:
559
560
561 // don't override this method, fix/enhance it with a patch to the module
562protected:
563 final processCmd(reference<string> rv);
564public:
565
566
567 // don't override this method, fix/enhance it with a patch to the module
568protected:
569 final doSubNegotiation();
570public:
571
573};
574
576
583
584public:
586 const ConnectionScheme = <ConnectionSchemeInfo>{
587 "cls": Class::forName("TelnetConnection"),
588 };
589
591
601 constructor(string name, string description, string url, hash attributes = {}, hash options = {})
602 ;
603
604
606 string getType();
607
608
610
614 *hash<auto> getRuntimeOptions();
615
616
618
625protected:
626 TelnetClient getImpl(bool connect = True, *hash rtopts);
627public:
628
629
631protected:
632 hash<ConnectionSchemeInfo> getConnectionSchemeInfoImpl();
633public:
634
635};
636};
setEventQueue()
Removes any Queue object so that socket events are no longer added to the Queue.
int getTerminalSpeed()
this method provides the value that will be given as the terminal speed in protocol negotiation
string getTarget()
Returns the connection target string.
log(string msg)
logs the message to the log closure set with the constructor (if any)
constructor(string host, softint port, *code log, *code dbglog)
creates the TelnetClient object
disconnect()
disconnects from the Telnet server
constructor(string connect, *code log, *code dbglog)
creates the TelnetClient object from a target string and optional log closure(s)
connect(timeout timeout=DefaultConnTimeout)
connects to the Telnet server
nothing clearWarningQueue()
Removes any warning Queue object from the Socket.
sendData(softlist arr)
sends data to the server
hash getWindowSize()
this method provides the value that will be given as the terminal window size in protocol negotiation
clearStats()
Clears performance statistics.
hash< auto > getUsageInfo()
Returns performance statistics for the socket.
bool isConnected()
returns True if the client is connected to the server
windowSizeUpdated()
this method should be called externally when the window size has changed
sendTextData(string str)
sends literal string data to the server; the text dat is converted to the socket's encoding if necess...
*string getTerminalType()
this method provides the value that will be given as the terminal type in protocol negotiation
nothing setWarningQueue(int warning_ms, int warning_bs, Queue queue, any arg, timeout min_ms=1s)
Sets a Queue object to receive socket warnings.
setUser(*string n_user)
sets or clears (in case passed with no value) the username parameter for logging in to the telnet ser...
*string getAvailableData(timeout t=DefaultTimeout)
returns all data available as a string (which could be an empty string if no data is available in the...
hash getEnvironment()
this method provides the value that will be given as the user's environment in protocol negotiation
destructor()
disconnects from the server if connected and deletes the object
bool hasFeature(int fc)
returns True if the server has confirmed with a DO command that it supports the given feature
logDbg(string msg)
logs the message to the debug log closure set with the constructor (if any)
*string getDisplay()
this method provides the value that will be given as the DISPLAY value in protocol negotiation
setEventQueue(Qore::Thread::Queue queue, auto arg, *bool with_data)
Sets a Queue object to receive socket events.
*string getUser()
returns the current value of the username parameter
class for Telnet connections; returns an object of class TelnetClient for connecting to telnet sessio...
Definition: TelnetClient.qm.dox.h:582
string getType()
returns "telnet"
hash< ConnectionSchemeInfo > getConnectionSchemeInfoImpl()
Returns the ConnectionSchemeInfo hash for this object.
constructor(string name, string description, string url, hash attributes={}, hash options={})
creates the RestConnection connection object
const ConnectionScheme
Connection entry info.
Definition: TelnetClient.qm.dox.h:586
TelnetClient getImpl(bool connect=True, *hash rtopts)
returns an TelnetClient object
*hash< auto > getRuntimeOptions()
returns runtime options
const CmdMap
command name map
Definition: TelnetClient.qm.dox.h:136
const OptMap
option map, maps codes to text descriptions
Definition: TelnetClient.qm.dox.h:196
contains constant definitions and the definition of the TelnetClient class
Definition: TelnetClient.qm.dox.h:95