[Twisted-web] Re: internet.TCPServer vs application.listenTCP

Alex Newby alex at alexnewby.com
Fri Jul 16 14:12:37 MDT 2004

Is there any particular reason why Nevow, generally, uses the following

application = service.Application("web")                                 
sc = service.IServiceCollection(application)                             
site = appserver.NevowSite(root, logPath="web.log")                      
i = internet.TCPServer(port, site)                                    

Instead of say:

application = app.Application("web", uid=uid, gid=gid)
site = appserver.NevowSite(root)
application.listenTCP(port, site, 'ip_address')

I needed to bind to a particular ip, and so am using the second and
haven't really noticed a difference. Forgive me if this is obvious.
Clearly listening to TCP, just going by the function names is not the
same as a TCP server.  
It bears mentioning that in your example, the application object isn't
really doing _anything_, because you're bypassing it when you start the
reactor directly. This application object is what "twistd -y" uses to

Below is what you'd need to change in your script to make this work.

root = static.File(pathToSiteRoot)
application = service.Application("web")
sc = service.IServiceCollection(application)
site = server.Site(root)
# --- snip ---
webserver = internet.TCPServer(port, site)

Let us know if this is what you're looking for.

Alex Levy
WWW: http://mesozoic.geecs.org

"Never let your sense of morals prevent you from doing what is right."
 -- Salvor Hardin, Isaac Asimov's _Foundation_

More information about the Twisted-web mailing list