#UDPHeartbeatServer.py #We will need the following module to generate randomized lost packets from socket import socket, AF_INET, SOCK_DGRAM def processMessage(socket): # Receive the client packet along with the address it is coming from message, address = socket.recvfrom(1024) id, start = message.split(';') print id, start #Create a UDP socket #Notice the use of SOCK_DGRAM for UDP packets serverSocket = socket(AF_INET, SOCK_DGRAM) # Assign IP address and port number to socket serverSocket.bind(('', 12000)) print "Awaiting data..." while True: try: processMessage(serverSocket) except KeyboardInterrupt: print "\nInterrupted by CTRL-C" break