Use Socket to connect to the forum
Socket is almost the base of the entire network communication. In this project, we will use Socket to connect to a designated server to obtain its information from the Internet. You can search many servers with telnet protocol on the Internet. By connecting to these servers, you can browse the web and forums, and even read character animation in the terminal!
We will connect to the "freechess.org" forum to get information in the terminal in this example. Enter the following code into the code editor:
from machine import Pin, I2C, ADC, UART, SPI, PWM
from time import sleep
N1 = network.WLAN_SPI(network.STA_IF)
lis = N1.scan()
for q in lis:
print(" ip gateway netmask MAC ssid")
addr_info = usocket.getaddrinfo('freechess.org',5000)
addr = addr_info[-1]
data = s.recv(500)
print(str(data, 'utf8'), end = '')
Pay attention to replace with your own WiFi name and password on line 17, then run the program and get the result in the Shell window. You can also find other servers that support the telnet protocol on the Internet, and then fill in the server address and port as shown. Now, you can use the terminal to visit these websites!
Tech Support & Product Discussion
if you have any technical issue. submit the issue into our forum. Thank you for choosing our products! We are here to provide you with different support to ensure that your experience with our products is as smooth as possible. We offer several communication channels to cater to different preferences and needs.