a very basic telnet CLIENT

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
fangis
Posts: 11
Joined: Mon Jul 24, 2017 11:03 pm

a very basic telnet CLIENT

Post by fangis » 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.

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




User avatar
Roberthh
Posts: 1735
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: a very basic telnet CLIENT

Post by Roberthh » Fri Jul 27, 2018 6:06 am

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

fangis
Posts: 11
Joined: Mon Jul 24, 2017 11:03 pm

Re: a very basic telnet CLIENT

Post by fangis » Wed Aug 01, 2018 12:21 am

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.

Post Reply