[Twisted-Python] "Ports" vs. "Listeners"

Glyph Lefkowitz glyph at twistedmatrix.com
Tue Jul 31 02:25:24 EDT 2001

On Mon, 30 Jul 2001, Matthew Walker wrote:

> "Port" to me suggests some sort of system resource, whereas "Listener" at
> least connotes something is being *done*. If indeed, we are talking about a
> class whose responsibility it is to receive requests and handle them, then a
> more active name such as "Listener" (or even "server") might be more
> appropriate.

Terms like "request", "receive", and "handle" in this context are
maddeningly vague. :)

And actually, your reasoning (although inverted) is the reason I chose the
word "Port".  The actual Port instance does nearly nothing except to
maintain state associated with the connection-accepting socket
(persistently, only what numeric port it's on); the associated
protocol.Factory instance generates Protocol instances, which "handle" the
incoming "requests", insofar as such a thing is ever done (they convert
the data into events and make appropriate callbacks to user code...)

"Listener" really implies to me that the user has to subclass it to make
it *do* something.  However, I'll agree that the word "listen" more
clearly implies what it is that a Port does specifically, so I'm more in
favor of deprecating direct use of the Port class, replacing it with
twisted.internet.main.Application.listenOn(...); I've already started
doing so.

                      ______      __   __  _____  _     _
                     |  ____ |      \_/   |_____] |_____|
                     |_____| |_____  |    |       |     |
                     @ t w i s t e d m a t r i x  . c o m

More information about the Twisted-Python mailing list