while True: data, add = sock.recvfrom(1024) if not bss.check(data, add, flag): break sock.close() bss.initialise(4, 3) UDP_IP = "127.0.0.1" thread = threading.Thread(target=receiver, args=("Receive", 0)) thread.start() print("Enter data to be sent. Enter \"exit\" to exit") message = input() while message != "exit": bss.update() message = message.replace(" ", "~") message += " " for i in bss.timestamp: message += str(i) + "," message += " " + str(bss.my_index) message = message.encode('utf-8') for i in range(len(flag)): if i != bss.my_index and flag[i] == 1: sock.sendto(message, (UDP_IP, IP[i])) message = input() message += " " bss.update() for i in bss.timestamp: message += str(i) + ","
global sock while True: data , add = sock.recvfrom(1024) if not bss.check(data, add, flag): break sock.close() bss.initialise(3,0) UDP_PORT = 5008 thread = threading.Thread(target = receiver , args = ("Receive" ,0 )) thread.start() print "Enter data to be sent. Enter \"exit\" to exit" message=raw_input() while message!="exit": bss.update() message = message.replace(" " ,"~") message += " " for i in bss.timestamp: message += str(i) + "," message += " " + str(bss.my_index) for i in range(len(flag)): if i != bss.my_index and flag[i] == 1: sock.sendto(message,(IP[i],UDP_PORT)) message = raw_input() message += " " bss.update() for i in bss.timestamp: message += str(i) + "," message += " " + str(bss.my_index) for i in range(len(flag)):