[medusa] newbie asyncore question on win9x
Sat, 30 Sep 2000 15:19:07 -0700 (PDT)
> I seem to be unable to get a simple test of asyncore to 'work'. I
> tried just a simple server/client pair (see below) but I never get a
> handle_recv event. I can see the connection being made between the
> slave accept port (some small port number like 13xx) and the master
> port (50007). After the master 'sends' data, the connection goes
> silently away. What am I not doing?
> class goer(asyncore.dispatcher_with_send):
> def __init__(self, sock,conn,addr,reader=None):
> asyncore.dispatcher.__init__ (self,conn)
The following four lines aren't necessary... the 'conn' parameter
initializes your 'goer' object directly via the above line. The steps
below are needed only for a server socket. A server socket's only
purpose is to accept connections and thus produce new sockets.
> self.create_socket (socket.AF_INET, socket.SOCK_STREAM)
Also, the 'sock' argument above is confusing - it's actually the
server object (of class 'checker') from below, a better name for this
parameter might be 'server'. I think if you just remove the four
lines above it will work.
> print 'goer=',sock,conn,addr
> def handle_read(self):
> print 'handle read'
> if self.reader != None: