#Imports modules
import socket
import time
listensocket = socket.socket() #Creates an instance of socket
Port = 8000 #Port to host server on
maxConnections = 999
IP = socket.gethostname() #IP address of local machine
listensocket.bind(('',Port))
#Starts server
listensocket.listen(maxConnections)
print("Server started at " + IP + " on port " + str(Port))
#Accepts the incoming connection
(clientsocket, address) = listensocket.accept()
print("New connection made!")
running = True
while running:
message = clientsocket.recv(1024).decode() #Gets the incoming message
print(message)
This sketch receives text from another computer and works great in python. When I run it in micro-python I get attribute error, object has no attribute 'gethostname'
I am trying to send text from my pc to ESP32(Cardcomputer). The python sketch I use to send the text works in both python and Micro-python without any modifications or problems.