asyncore problem

Adonis deltapigz at telocity.com
Sat Aug 3 00:06:57 CEST 2002


im just sinking my teeth into the asyncore module and have followed the
documentation closely and have googled around to no avail, and have been
unable to get it working. no errors are raised, nothing at that, and the
events are not being triggered, am i missing something in my code?

by the way, the echo server it is conencting to acknowledges its presence
and does send back data.

any help would greatly be appreciated.

Adonis

-- paste --

import asyncore, socket

class PYCHAT_SOCKET(asyncore.dispatcher):
    def __init__(self, ip, port):
        asyncore.dispatcher.__init__(self)
        self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
        self.connect((ip, port))
        self.buffer = 'test'

    def handle_close(self):
        print '[SOCKET] Disconnected'

    def handle_connect(self):
        print '[SOCKET]Connected'

    def handle_read(self):
        print self.recv(1024)

    def writable(self):
        return (len(self.buffer) > 0)

    def handle_write(self):
        sent = self.send(self.buffer)
        self.buffer = self.buffer[sent:]

x = PYCHAT_SOCKET('64.192.160.45', 7)





More information about the Python-list mailing list