Why does the message send only once?
usenet-mail-0306.20.chr0n0ss at spamgourmet.com
Tue Oct 16 19:16:35 CEST 2007
> 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
> 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).
BOFH excuse #168:
le0: no carrier: transceiver cable problem?
More information about the Python-list