我目前正在做一个在 mac os 山狮上创建 TCP 服务器的项目。我写了一个脚本叫做:Server.py
在这个 python 脚本中,我使用了 twisted 来监听端口 80,如下所示:
reactor.listenTCP(80, factory)
reactor.run()
我怎么会收到这样的错误:
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/twisted/internet/posixbase.py", line 436, in listenTCP
p.startListening()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/twisted/internet/tcp.py", line 641, in startListening
raise CannotListenError, (self.interface, self.port, le)
twisted.internet.error.CannotListenError: Couldn't listen on any:80: [Errno 13] Permission denied.
我在想是不是因为 tcp.py 脚本对管理员用户有错误的权限?或者有没有办法在端口 < 1024 上设置权限?(更改权限,对这样的服务器的安全性有何影响?)
任何更好的解决方案都值得关注。