eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'TelnetClient':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: TelnetClient


Inheritance:

   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)

Description:


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


Related information:

    TelnetTool
    TerminalView

Class protocol:

debugging
o  verbose

o  verbose: aBoolean

initialization
o  initialize
self initializeMappings "/ done lazily now

o  initializeMappings
* interpret as command: */

usage example(s):

     self initializeMappings

instance creation
o  new
(comment from inherited method)
return an instance of myself without indexed variables


Instance protocol:

accessing
o  connectionBrokenAction: aBlock
set the action which is evaluated when the connection is broken

o  disconnect
Transcript showCR:'*** disconnect'.

o  newConnection: aSocket

o  outputStream
return the value of the instance variable 'outputStream' (automatically generated)

o  outputStream: something
set the value of the instance variable 'outputStream' (automatically generated)

o  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
o  initialize
super initialize.

queries
o  isConnected

stream protocol
o  nextPut: aCharacter
send that character to my telnet partner

o  nextPutAll: aString
send some characters to my telnet partner

o  nextPutByte: aByte
send that character to my telnet partner

o  nextPutBytes: count from: anObject startingAt: start
write count bytes from an object starting at index start to my telnet partner

o  nextPutLine: aString

o  sendCommand: aCmdSymbol option: anOptionOrNil

o  sendDO: option

o  sendDONT: option

o  sendSB: option

o  sendSBCommand: aCmdSymbol option: anOption subOption: subOption

o  sendSE

o  sendWILL: option

o  sendWONT: option

telnet protocol
o  readerProcessForever
bug under windows...

o  startReaderProcess

o  stopReaderProcess

telnet protocol - state machine
o  handleSB: sb data: sbData

o  handleSB_TELOPT_TTYPE: sbData
TELQUAL_SEND

o  stateDATA: inByte
a byte is coming in data mode

o  stateDO: inByte
please do option

o  stateDONT: inByte
please do not option

o  stateIAC: inByte
a byte is coming after IAC was received

o  stateSB: inByte
sub

o  stateSBDATA: inByte
sub-data

o  stateSBDATAIAC: inByte
sub-data

o  stateSBIAC: inByte
sub-iac

o  stateWILL: inByte
please do option

o  stateWONT: inByte
please dont option


Demonstration:


    TelnetTool open


Examples:



    |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.


ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Fri, 16 Apr 2021 10:06:40 GMT