Cherrypy 无法在 WinXP 上创建套接字
Python 2.7、Cherrypy 3.2.0、Windows XP SP3。
当绑定到 127.0.0.1 端口 8080 时,Cherrypy 应用程序使用快速启动可以正常工作,但是任何绑定到实际 IP 的尝试都会导致
文件“C:\Python27\lib\site-packages\cherrypy\wsgiserver__init__.py”,第 175 行 3、在启动时 引发套接字错误(消息) 错误:无法创建套接字
...我认为这与 XP 不允许绑定到原始套接字有关。
当作为服务运行时,我已经能够获得套接字,但是调试服务并不令人愉快。
我来自unix环境,所以要温柔。 /边缘射击
Python 2.7, Cherrypy 3.2.0, Windows XP SP3.
Cherrypy app works fine using quickstart when binding to 127.0.0.1 port 8080, however any attempt to bind to actual IP results in
File "C:\Python27\lib\site-packages\cherrypy\wsgiserver__init__.py", line 175
3, in start
raise socket.error(msg)
error: No socket could be created
... which I assume is related to XP not allowing one to bind to raw sockets.
I have been able to get a socket when running as a service, but debugging a service is not pleasant.
I'm coming from a unix environment, so be gentle. /rimshot
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Windows 发现 #1:XP Service Pack 2 显然不再允许绑定到原始套接字,作为“避免黑客”的手段。因此,要成功绑定到套接字,必须使用 python win32 utils 和cherrypy 创建一个 Windows 服务,结果证明这简直是小菜一碟!
可以在 http://tools 中找到出色的“第一次或第二次尝试工作方法” .cherrypy.org/wiki/WindowsService。我发现这个特定的 Windows 服务与 unix 守护进程一样难以调试......因此了解 Cherrypy 的日志记录是如何工作的!
Windows discovery #1: XP Service Pack 2 apparently ceased to allow binding to raw sockets as a "hacker avoidance" something-or-other. So, to successfully bind to a socket one must use python win32 utils and cherrypy to create a windows service, which turned out to be pretty much cake!
An excellent, work-on-the-first-or-second-try howto is found at http://tools.cherrypy.org/wiki/WindowsService. I have found that this particular windows service was about as hard to debug as a unix daemon ... therefore understand how cherrypy's logging works!