I have a simple TCP server using the socketserver
library. It used to work fine, but now I get this error message whenever I run it:
socket.error: [Errno 10048] Only one usage of each socket address (protocol/network address/port) is normally permitted
Here is the code:
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()
I've tried changing the port, but I get the same error. What is the problem?