Sep-23-2021, 01:52 AM
Hello, I'm trying to create a chat room with socket.
The messages from the other user only show up when the other user types in a message.
The messages from the other user only show up when the other user types in a message.
import socket HEADER = 64 PORT = FORMAT = 'utf-8' DISCONNECT_MESSAGE = "!DISCONNECT" SERVER = ADDR = (SERVER, PORT) client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client.connect(ADDR) def send(msg): message = msg.encode(FORMAT) msg_length = len(message) send_length = str(msg_length).encode(FORMAT) send_length += b' ' * (HEADER - len(send_length)) client.send(send_length) client.send(message) print(client.recv(2048).decode(FORMAT)) while True: message = str(input("Message: ")) send(message)(I'm new to posting, sorry if I don't format everything properly)