import socket, threading
HOST = '0.0.0.0'
PORT = 8080
ServerSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ServerSocket.bind((HOST, PORT))
ServerSocket.listen()
CurrentConnections = []
print(f"Server listening on {HOST}:{PORT}...")
def ReceiveClient(Connection):
while True:
RawData = Connection.recv(1024)
Data = RawData.decode("utf-8")
print(f"Echoing {Data}")
for OConnection in CurrentConnections:
OConnection.send(RawData)
while True:
Connection, Address = ServerSocket.accept()
if Connection in CurrentConnections:
continue
print(f"Got new connection for {Address}")
CurrentConnections.append(Connection)
threading.Thread(target=ReceiveClient, args=(Connection,)).start()
this code above works perfectly for my local machine. But when I try running it in render it spams “Echoing”, then errors. Anyone know how to fix this?