def handle_read(self): data = self.recv(8192) self.data_len = len(data) if data: conn = Adapt(self.send) # Now your conn have method sendall() data_judge = data Dispatch(data, conn)
def handle_read(self): data = self.recv(8192) self.data_len = len(data) if data: try: conn = Adapt(self.send) # Now your conn have method sendall() data_judge = data Dispatch(data, conn) except Exception, e: f.write('B11G:'+str(time.time())+'\n'+str(e))
def handle_read(self): data = self.recv(8192) # 接收发送的数据 self.data_len = len(data) # 统计数据长度 if data and IS_NEED_RSP: # 判断现在是否允许发送数据 try: conn = Adapt(self.send) # Now your conn have method sendall() #data_judge = data Dispatch(data, conn) # 开始解析接收到的数据 except Exception, e: print e
def handle_read(self): data = self.recv(8192) self.data_len = len(data) if data: try: conn = Adapt(self.send) # Now your conn have method sendall() data_judge = data Dispatch(data, conn) except Exception, e: #global f print e
info(info_self) sock.bind(server_address) # Calling listen() puts the socket into server mode, # and accept() waits for an incoming connection # Listen for incoming connection sock.listen(1) while True: # Wait for a connection info('waiting for a connection') connection, client_address = sock.accept() try: info_one = 'connection from ' + str(client_address) info(info_one) # Receive the data in small chunks and retransmit it while True: data = connection.recv(1024) if data: # dispatch_sample(data.strip('\n'), connection) Dispatch(data, connection) pass else: warn_one = 'no more data from %s' + str(client_address) warning(warn_one) break finally: # clean up the connection connection.close()