#!/usr/bin/python import thread, time from socket import * myHost = 'silo.cs.indiana.edu' myPort = 15854 users = [] sockobj = socket(AF_INET, SOCK_STREAM) sockobj.bind((myHost, myPort)) sockobj.listen(10) def now(): return time.ctime(time.time()) def handleClient(connection): time.sleep(5) while True: data = connection.recv(1024) if not data: break for conn in users: # added conn.send('Echo=>%s at %s\n' % (data, now())) # modified connection.close() print "client has disconnected" # added def dispatcher(): while True: connection, address = sockobj.accept() print 'Server connected by', address, print 'at', now() users.append(connection) # added thread.start_new(handleClient, (connection,)) dispatcher()