#!/usr/bin/env python import socket TCP_IP = '127.0.0.1' TCP_PORT = 33001 BUFFER_SIZE = 1024 fraw = open("basestation_format_raw.txt","wb") soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) soc.connect((TCP_IP, TCP_PORT)) while (True): data = soc.recv(BUFFER_SIZE) fraw.write(data) print ("received data:", data) soc.close()