UDP Echo Server with python version 20150802
This is a upgraded python echo server of UDP Server by Python - Shammerism. Upgraded point is server side message to include client socket information.
#!/usr/bin/env python import socket from contextlib import closing from time import ctime host = '0.0.0.0' port = 12345 bufsize = 4096 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) with closing(sock): sock.bind((host, port)) while True: message, client = sock.recvfrom(bufsize) print message + ' from ' + client[0] + ':' + str(client[1]) sock.sendto('[%s] %s' % (ctime(), message), client)