我有一个使用socketserver
库的简单TCP服务器。它曾经工作正常,但现在我运行它时收到此错误消息:
socket.error: [Errno 10048] Only one usage of each socket address (protocol/network address/port) is normally permitted
以下是代码:
class Handler(socketserver.StreamRequestHandler):
def handle(self):
sys.stdout = self.wfile
self.data = str(self.request.recv(1024).strip(), "utf-8")
exec(self.data, globals())
def handle_error(request, client_address):
print("Quitting...")
if __name__ == "__main__":
HOST, PORT = "localhost", 5555
server = socketserver.TCPServer((HOST, PORT), Handler)
server.serve_forever()
我尝试过改变端口,但是我得到了同样的错误。有什么问题?