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.45 date: 2023/12/13 08:48:50
user: cg
file: TelnetClient.st directory: goodies/communication
module: stx stc-classLibrary: communication

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

copyright

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

Class protocol:

debugging
o  verbose

o  verbose: aBoolean

initialization
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.
Return the number of bytes written.

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
give the process a chance to really terminate

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


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.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 04:22:22 GMT