asyncore: select on UDP socket question

Feiyi Wang fwang2 at mcnc.org
Wed Oct 4 17:45:50 EDT 2000


Hi, 

I have some trouble of using "asyncore" for UDP based server (the examples
I have seen are all TCP based): I will first describe the problem I ran
into, then the sample code.

(1) once the server call "asyncore.loop()", I saw a flood of messages
saying that "write unhandled", obviously "handld_write()" is called, but
why? no one is writing to that private port.

(2) there is always "log: adding channel <asynCE  at 80e9d68>" printed out
and I can't get rid of it.

In general, i don't think I am using the package in the right way, please
help, here is the sample code on server:


class asynServer(asyncore.dispatcher):
    def __init__(self, port):
        asyncore.dispatcher.__init__(self)
        self.create_socket(AF_INET, SOCK_DGRAM)
        self.bind(("", port))
    # received an incoming connection

    def handle_read(self):
        K=1024
        try:
            data, address = self.recvfrom(64*K)
            print address[0], "said : \n", data
        ...

asynServer(6000)
asyncore.loop()


Thanks

Feiyi




More information about the Python-list mailing list