简单的SocketServer - 客户端在第一次请求后无法工作

时间:2016-01-28 23:17:47

标签: python python-2.7 server socketserver

我正在尝试创建一个简单的服务器。此服务器应该能够处理来自多个客户端的请求。问题是,在一个客户的第二次请求之后,它会引发:class Book < ActiveRecord::Base belongs_to :author alias_method :set_author, :author= def author=(author) author = Author.find_or_initialize_by_name(author) if author.is_a? String set_author(author) end end

socket.error: [Errno 10053] An established connection was aborted by the software in your host machine

CONSOLE:

class ThreadedTCPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
    daemon_threads = True


class ThreadedTCPRequestHandler(SocketServer.BaseRequestHandler):
    def handle(self):

        data = self.request.recv(1024)
        output = data
        response = "{}".format(output)
        self.request.sendall(response)


if __name__ == "__main__":
    HOST, PORT = _host, int(_port)
    server = ThreadedTCPServer((HOST, PORT), ThreadedTCPRequestHandler)
    ip, port = server.server_address

    print "Running on: %s:%s" % (HOST, PORT)
    server.serve_forever()

修改

如果有帮助:

client.py

CLIENT1->SERVER > anything
SERVER->CLIENT1 > anything
CLIENT1->SERVER > anything
socket.error: [Errno 10053] An established connection was aborted by the software in your host machine

0 个答案:

没有答案