Aaron Watters wrote: > On Nov 22, 9:53 am, Tzury Bar Yochay <[EMAIL PROTECTED]> wrote: >> The following is a code I am using for a simple tcp echo server. >> When I run it and then connect to it (with Telnet for example) if I >> shout down the telnet the CPU tops 100% of usage and saty there >> forever.... >> def handle(self): >> while 1: >> data = self.request.recv(1024) >> self.request.send(data) >> if data.strip() == 'bye': >> return > ... Try changing it to ... > data = "dummy" > while data: > ...
Even better: from functools import partial def handle(self): for data in iter(partial(self.request.recv, 1024), ''): self.request.send(data) if data.strip() == 'bye': break else: raise ValueError('Gone w/o a "bye"') # or IOError -Scott -- http://mail.python.org/mailman/listinfo/python-list