Jan-14-2020, 07:46 AM
Hi, I commited this little echo server for testing purposes. The only thing I don't like, that I cannot stop or exit from the client side.
I'd like to break the while loop if the client sends a 'q' or 'quit'.
I'd like to break the while loop if the client sends a 'q' or 'quit'.
import socket
import time
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ip = 'localhost'
port = 2323
try:
s.bind((ip, port))
except OSError:
print("error")
print("[*] Server started, port {}".format(port))
s.listen(1)
conn, client_ip = s.accept()
while 1:
print('[*] Connected client: {}'.format(client_ip))
conn.send(b'AAAA:BBBB,018:233,CCCC:DDDD\n')
time.sleep(1)
conn.close()Could you please help me?
