示例#1
0
 def __init__(self, host, port, info):
     Handler.__init__(self)
     threading.Thread.__init__(self)
     self._host = host
     self._port = port
     self._info = info
     self._sock_host = None
     self._sock_port = 0
     self._peer_host = None
     self._peer_port = 0
     self._thread_stop = False
     self._peer_send_count = 0
     self._peer_recv_count = 0
     self._peer_state = ''
     self._socket = None
示例#2
0
 def __init__(self, host, port, info):
     self._clients = []
     self._servers = []
     self._manager = None
     self._host = host
     self._port = port
     self._info = info
     self._sock_host = None
     self._sock_port = 0
     self._peer_host = None
     self._peer_port = 0
     self._peer_send_count = 0
     self._peer_recv_count = 0
     self._thread_stop = False
     Handler.__init__(self)
     threading.Thread.__init__(self)
示例#3
0
    def start(self):
        try:
            server = socket.socket()
            server.setblocking(0)
            server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
            server.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)

            server.bind((self._host, self._port))
            server.listen(5)
            self._sock_host, self._sock_port = s.getsockname()
            self._peer_state = 'LISTENING'
            self._servers.append(server)
            self._clients.append(server)
            Handler.start(self)
            threading.Thread.start(self)
        except Exception as ex:
            logging.exception(ex)
            return None
示例#4
0
 def stop(self):
     self._thread_stop = True
     self.join(2)
     Handler.stop(self)
示例#5
0
 def start(self):
     Handler.start(self)
     threading.Thread.start(self)
示例#6
0
 def clean_count(self):
     Handler.clean_count(self)
     self._peer_send_count = 0
     self._peer_recv_count = 0