Page 1 of 1

a very basic telnet CLIENT

Posted: Fri Jul 27, 2018 12:20 am
by fangis
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.

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() 




Re: a very basic telnet CLIENT

Posted: Fri Jul 27, 2018 6:06 am
by Roberthh
There is a telnet server made by @chrisgp, which was made for ESP8266, but should also work on the recent firmware version of the ESP32.
https://github.com/cpopp/MicroTelnetServer

Re: a very basic telnet CLIENT

Posted: Wed Aug 01, 2018 12:21 am
by fangis
Hi Roberthh, thanks, but this is an attempt to build a client, not a server! It's not for connecting to the Esp over wifi; it's to connect from the ESP to other sites/servers.