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)
Larz60+ write Sep-23-2021, 04:29 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use bbcode tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use bbcode tags on future posts.