0 ' Developed by Eugeny Brychkov 05 Sep 2017 1 ' Requires firmware datecode 20170905 or later 2 ON STOP GOSUB 300:STOP ON:ON ERROR GOTO 300 10 PRINT"This program emulates line-based" 20 PRINT"telnet peer using TCS: device":PRINT"Press CTRL-STOP to end application" 30 PRINT"Press any key to continue":A$=INPUT$(1):PRINT 40 PRINT"Perform telnet to port 23" 50 PRINT"to IP address ";:CALLNETIP:PRINT 60 ' Set source port 23 and open in server mode 70 CALLNETSETPORT(,23):OPEN"TCSA:"AS#1 80 ' Check if there's a connection, loop if not 90 PRINT:PRINT"Waiting for connection" 100 IF EOF(1) THEN 100 110 PRINT"Connected":PRINT:PRINT#1,"Type ";CHR$(34);"quit";CHR$(34);" to end session":PRINT#1,"" 120 ' Wait for line from the remote connected peer 130 LINEINPUT#1,A$:PRINT"Remote: ";A$ 140 ' Perform reversion of received string 150 A=LEN(A$):B$="":IF A>0 THEN FOR I=A TO 1 STEP -1:B$=B$+MID$(A$,I,1):NEXT I 160 ' Replying to remote peer with reversed string 170 PRINT"Reply: ";B$ 180 PRINT#1,B$ 190 ' Checking if we are asked to drop connection 200 IF A$="quit" THEN PRINT"Session finished":CLOSE #1:GOTO 70 210 ' Checking if connection is dropped, then close and go reopen 220 IF EOF(1) THEN PRINT"Connection ended":CLOSE #1:GOTO 70 230 ' If connection is still there, continue getting input 220 GOTO 130 300 CLOSE #1:CALLNETSETPORT(,80):ON ERROR GOTO 0:STOP OFF 310 PRINT:PRINT"Application finished":END