All pastes #762640 Raw Edit

raw_chat

public python v1 · immutable
·published 2007-11-05 20:25 UTC
rendered paste body
import asynchatimport socketimport asyncoreclass ChatClient(asynchat.async_chat):    def __init__(self, addr, term):        asynchat.async_chat.__init__(self)        self.buf = ""        self.set_terminator(None)        self.create_socket(socket.AF_INET, socket.SOCK_STREAM)        self.set_terminator(term)        self.connect(addr)    def collect_incoming_data(self,data):        self.buf += data    def start(self):        asyncore.loop()    def step(self):        asyncore.loop(count = 1)    def found_terminator(self):        self.in_(self.buf)        self.buf = ""    def handle_connect(self):        pass    def in_(self,data):        raise NotImplementedError