Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python echo server
#1
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'.

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?
Reply


Messages In This Thread
python echo server - by kerzol81 - Jan-14-2020, 07:46 AM
RE: python echo server - by Gribouillis - Jan-14-2020, 08:40 AM
RE: python echo server - by codexcotechnologies - Jan-16-2020, 06:01 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Paramiko Server -- Exception (server): Error reading SSH protocol banner ujlain 3 4,746 Jul-24-2023, 06:52 AM
Last Post: Gribouillis
  sending packet onto dummy network device but receiving echo sabuzaki 2 1,493 Feb-12-2023, 10:31 AM
Last Post: Vadanane

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020