dispatcher class in asyncore














































dispatcher class in asyncore



class asyncore.dispatcher:

The dispatcher class is a thin wrapper around a low-level socket object. To make it more useful, it has a few methods for event-handling which are called from the asynchronous loop. Otherwise, it can be treated as a normal non-blocking socket object.

The firing of low-level events at certain times or in certain connection states tells the asynchronous loop that certain higher-level events have taken place. For example, if we have asked for a socket to connect to another host, we know that the connection has been made when the socket becomes writable for the first time (at this point you know that you may write to it with the expectation of success). The implied higher-level events are:

Event

Description

handle_connect()

Implied by the first read or write event

handle_close()

Implied by a read event with no data available

handle_accepted()

Implied by a read event on a listening socket


During asynchronous processing, each mapped channel%u2019s readable() and writable() methods are used to determine whether the channel%u2019s socket should be added to the list of channels select()ed or poll()ed for read and write events.

next we will discuss about functions that we can override under dispatcher class

Comments