Answer the question
In order to leave comments, you need to log in
How to stop "Space" spam on the server after closing the client?
I made a small local chat, but after the Client part is closed, "Space" spam starts on the server. How can this be fixed?
server
host = socket.gethostbyname_ex(socket.gethostname())[-1][-1]
port = 6677
print(socket.gethostbyname_ex(socket.gethostname()))
print(host)
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind((host, port))
s.listen()
while True:
conn, addr = s.accept()
while True:
data = conn.recv(1024).decode('utf-8').lower()
print(data)
import socket
HOST='192.168.0.13'
PORT= 6677
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((HOST, PORT))
while True:
s.send(input().encode('utf-8')
Answer the question
In order to leave comments, you need to log in
while True:
data = conn.recv(1024).decode('utf-8').lower()
print(data)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question