websocket shenanigans worky

This commit is contained in:
2024-09-26 13:20:46 +02:00
parent 465634e1cd
commit e2d2c41ad4
2 changed files with 6 additions and 6 deletions

View File

@@ -1,19 +1,20 @@
import socket
HOST = "127.0.0.1" # Standard loopback interface address (localhost)
HOST = "127.0.0.1" # Listen on all available interfaces
PORT = 4024 # Port to listen on (non-privileged ports are > 1023)
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind((HOST, PORT))
s.listen()
print(f"Server listening on {HOST}:{PORT}")
conn, addr = s.accept()
with conn:
print(f"Connected by {addr}")
conn.sendall(b"hallo")
conn.sendall(b"hallo\n")
while True:
data = conn.recv(2048)
if data:
print("received", repr(data))
conn.sendall(b"message received")
print("Received:", repr(data))
conn.sendall(b"message received\n")
if not data:
break