Why does the message send only once?
Bjoern Schliessmann
usenet-mail-0306.20.chr0n0ss at spamgourmet.com
Tue Oct 16 13:16:35 EDT 2007
More information about the Python-list mailing list
Tue Oct 16 13:16:35 EDT 2007
- Previous message (by thread): Why does the message send only once?
- Next message (by thread): Build Python 2.5 against Tk 8.5
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
danfolkes wrote: > Why does the message send only once? Because your server is designed to only accept one connection, wait forever except there is an exception, and quit thereafter. > def Server(address): > [...] > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > s.bind((HOST, PORT)) > s.listen(1) # ----- set up listening > conn, addr = s.accept() # ----- accept one connection > print 'Connected by', addr > while 1: > print message > time.sleep(1) > data = conn.recv(1024) # ----- receive stuff > #if not data: break > conn.send(data) # ----- send stuff > conn.close() # ----- close connection > # ----- quit Personally, I like the Twisted framework more than low-level socket interfaces. Consider giving it a try -- your code will be much easier to read and maintain. You don't have to waste time implementing the server or client basics but can fully concentrate on your protocol(s). Regards, Björn -- BOFH excuse #168: le0: no carrier: transceiver cable problem?
- Previous message (by thread): Why does the message send only once?
- Next message (by thread): Build Python 2.5 against Tk 8.5
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list