Reputation: 6176
I wonder how I can run tornado web application using regular sockets, so that I can access each socket directly for getsockopt/setsockopt. Basically, what I want to do is to get tcp_info of the listening sockets.
Upvotes: 0
Views: 549
Reputation: 24007
Try this:
from tornado import httpserver, ioloop, netutil, web
class MainHandler(web.RequestHandler):
def get(self):
self.write("Hello, world")
application = web.Application([
(r"/", MainHandler),
])
sockets = netutil.bind_sockets(8888)
for s in sockets:
print s
server = httpserver.HTTPServer(application)
server.add_sockets(sockets)
ioloop.IOLoop.instance().start()
application.listen(8888)
ioloop.IOLoop.instance().start()
More info is in the HTTPServer docs, in the section about "advanced multi-process".
Upvotes: 4