|
Class: TelnetClient
Object
|
+--TelnetClient
- Package:
- stx:goodies/communication
- Category:
- Net-Communication-Telnet
- Version:
- rev:
1.38
date: 2018/10/09 10:15:04
- user: cg
- file: TelnetClient.st directory: goodies/communication
- module: stx stc-classLibrary: communication
- Author:
- Claus Gittinger (cg@exept.de)
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
TelnetTool
TerminalView
debugging
-
verbose
-
-
verbose: aBoolean
-
initialization
-
initialize
-
self initializeMappings "/ done lazily now
-
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
-
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
-
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
TelnetTool open
|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.
|
|