Before I start I want to say that i'm 14 and this might or might not sound dumb. So I was working on a python project and I'm almost done with it but except 1 part. I want to make this:
"Make the socket, handle the connection to it, then send your menu over the socket" Can someone help me with this? I 'made' an socket already.
This is the code -->
#!/usr/bin/env python3
import socket
HOST = '46.101.xxx.xxx'
PORT = 65432
printed = False
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind((HOST, PORT))
s.listen()
conn, addr = s.accept()
with conn:
print('Connected by', addr)
while True:
data = conn.recv(1024)
if not data:
if not printed:
print('Disconnected by', addr)
printed = True
conn.sendall(data)