|
Class: TelnetClient
Object
|
+--TelnetClient
- Package:
- stx:goodies/communication
- Category:
- Net-Communication-Telnet
- Version:
- rev:
1.45
date: 2023/12/13 08:48:50
- user: cg
- file: TelnetClient.st directory: goodies/communication
- module: stx stc-classLibrary: communication
Implements the telnet client protocol.
Provides limited writeStream protocol, allowing
data to be sent to the partner via #nextPut: like protocol.
Input arriving from the telnet partner is forwarded to my outputStream.
A concrete application is found in TelnetTool, which connects me
to a TerminalView.
[instance variables:]
connection <Socket> the telnet connection
outputStream <Stream> data arriving from the
telnet connection is forwarded
to that stream.
state <Symbol> the telnet protocol state.
sb, sbData internal buffer for
SB..SE data
copyrightCOPYRIGHT (c) 1998 by eXept Software AG
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
debugging
-
verbose
-
-
verbose: aBoolean
-
initialization
-
initializeMappings
-
* interpret as command: */
Usage example(s):
instance creation
-
new
-
(comment from inherited method)
return an instance of myself without indexed variables
accessing
-
connectionBrokenAction: aBlock
-
set the action which is evaluated when the connection is broken
-
disconnect
-
Transcript showCR:'*** disconnect'.
-
newConnection: aSocket
-
-
outputStream
-
return the value of the instance variable 'outputStream' (automatically generated)
-
outputStream: something
-
set the value of the instance variable 'outputStream' (automatically generated)
-
terminalType: something
-
what we tell the partner, what the terminal looks like.
If never set, it defaults to either 'dumb' or 'vt100', depending on the outStream
initialization
-
initialize
-
super initialize.
queries
-
isConnected
-
stream protocol
-
nextPut: aCharacter
-
send that character to my telnet partner
-
nextPutAll: aString
-
send some characters to my telnet partner
-
nextPutByte: aByte
-
send that character to my telnet partner
-
nextPutBytes: count from: anObject startingAt: start
-
write count bytes from an object starting at index start to my telnet partner.
Return the number of bytes written.
-
nextPutLine: aString
-
-
sendCommand: aCmdSymbol option: anOptionOrNil
-
-
sendDO: option
-
-
sendDONT: option
-
-
sendSB: option
-
-
sendSBCommand: aCmdSymbol option: anOption subOption: subOption
-
-
sendSE
-
-
sendWILL: option
-
-
sendWONT: option
-
telnet protocol
-
readerProcessForever
-
bug under windows...
-
startReaderProcess
-
-
stopReaderProcess
-
give the process a chance to really terminate
telnet protocol - state machine
-
handleSB: sb data: sbData
-
-
handleSB_TELOPT_TTYPE: sbData
-
TELQUAL_SEND
-
stateDATA: inByte
-
a byte is coming in data mode
-
stateDO: inByte
-
please do option
-
stateDONT: inByte
-
please do not option
-
stateIAC: inByte
-
a byte is coming after IAC was received
-
stateSB: inByte
-
sub
-
stateSBDATA: inByte
-
sub-data
-
stateSBDATAIAC: inByte
-
sub-data
-
stateSBIAC: inByte
-
sub-iac
-
stateWILL: inByte
-
please do option
-
stateWONT: inByte
-
please dont option
|connection telnetClient stream|
Verbose := true.
[
stream := WriteStream on:''.
connection := Socket
newTCPclientToHost:'rainmaker.wunderground.com'
port:23.
connection notNil ifTrue: [
telnetClient := TelnetClient new.
telnetClient connectionBrokenAction:[connection close].
telnetClient terminalType:'dumb'.
telnetClient outputStream:stream.
telnetClient newConnection:connection.
telnetClient nextPutAll:(String crlf).
Delay waitForSeconds:1.
telnetClient nextPutLine:'nyc'.
Delay waitForSeconds:1.
telnetClient nextPutLine:'x'.
Delay waitForSeconds:1.
].
] ensure:[
connection notNil ifTrue:[
telnetClient disconnect.
]
].
stream contents inspect.
|
|connection telnetClient stream|
Verbose := true.
[
stream := WriteStream on:''.
connection := Socket
newTCPclientToHost:'localhost'
port:23.
connection notNil ifTrue: [
telnetClient := TelnetClient new.
telnetClient connectionBrokenAction:[connection close].
telnetClient terminalType:'dumb'.
telnetClient outputStream:stream.
telnetClient newConnection:connection.
Delay waitForSeconds:1.
telnetClient nextPutLine:''.
Delay waitForSeconds:1.
].
] ensure:[
connection notNil ifTrue:[
telnetClient disconnect.
]
].
stream contents inspect.
|
|