Quote:as a class:
Client.py
import socket class Client: def __init__(self): self.HOST = '192.168.1.59' # The server's hostname or IP address, NodeMCU IP Address self.PORT = 80 # The port used by the server, PORT NUMBER in ARDUINO CODE def transfer_data(self): s.connect((HOST, PORT)) s.sendall(b'Hello, world') self.data = s.recv(1024) # To try run stand-alone if __name__ == '__main__': cl = Client() cl.transfer_data() print(cl.data)
I tried. What should i do ?