def _queue_linesplit(self): ss = SocketServer(host='localhost', port=8888) ss.create() self.lg.info('8888 Waiting connection...') while True: ss.accept() self.lg.info('Connection Accepted!') self.lg.info('8888 Waiting for stream...') data = ss.recv() while data != '\n': self.tq.put(data) data = ss.recv() self.tq.put(data) ss.close()
def run(self, lg): self.lg = lg ss = SocketServer(host='localhost', port=9999) ss.create() self.lg.info('9999 Waiting connection...') while True: ss.accept() while True: with open('res/results.txt', 'a') as outfile: try: data = ss.recv() outfile.write(data) except: logging.warning('Connection with 9999 losed') break ss.close()