gpt4 book ai didi

Python twisted reactor - 地址已被使用

转载 作者:太空狗 更新时间:2023-10-29 19:30:34 25 4
gpt4 key购买 nike

我正在学习教程 http://www.raywenderlich.com/3932/how-to-create-a-socket-based-iphone-app-and-server用于在 Mac OS X 环境中使用套接字编程创建示例。

我正在使用 post 80 编写 reactor.listenTCP(80, factory)。当我运行 server.py 文件时,出现错误:

File "server.py", line 10, in <module>
reactor.listenTCP(6, factory)
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 48] Address already in use.

源码如下:

from twisted.internet.protocol import Factory, Protocol
from twisted.internet import reactor

class IphoneChat(Protocol):
def connectionMade(self):
self.factory.clients.append(self)
print "clients are ", self.factory.clients

def connectionLost(self, reason):
self.factory.clients.remove(self)

factory = Factory()
factory.protocol = IphoneChat
factory.clients = []
reactor.listenTCP(80, factory)
print "Iphone Chat server started"
reactor.run()

如果我使用的不是 6 之类的另一个端口,它工作正常。我只是想知道,如何将端口 80 用于同一个应用程序。

最佳答案

打开事件监视器,搜索 Python 并终止进程。您可能搞砸了一次关闭服务器。

关于Python twisted reactor - 地址已被使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14640711/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com