a very basic telnet CLIENT
Posted: Fri Jul 27, 2018 12:20 am
Hi
this is working for me for talking with simple servers using the esp. Its of course
limited and it will break on interactive sessions i.e those that refresh the screen.
I post it because when I first joined i really wanted to find such code and never was able to.
Corrections / improvements welcome, I was unable to make it keypress-based for example.
this is working for me for talking with simple servers using the esp. Its of course
limited and it will break on interactive sessions i.e those that refresh the screen.
I post it because when I first joined i really wanted to find such code and never was able to.
Corrections / improvements welcome, I was unable to make it keypress-based for example.
Code: Select all
import socket
import time
import gc
def start():
serv = input("Servidor:\r\n")
porta = input("porta:\r\n")
addr_info = socket.getaddrinfo(serv, int(porta))
addr = addr_info[0][-1]
del serv
del porta
s = socket.socket()
s.connect(addr)
del addr
del addr_info
s.settimeout(0.5)
d = "."
while d:
try:
d = s.recv(500)
print (str(d, 'utf8'))
except OSError:
i = input()
i = i + ("\n")
s.sendall(i)
print("\r\n\r\nExecution finie\r\n")
s.close()
del s
del i
del d
gc.collect()