import socket, sys, os sock = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) host = '' port = 5001 sock.bind( (host,port) ) sock.listen(1) while True: conn, addr = sock.accept() flo = conn.makefile('r', 0) while True: try: msg = flo.readline() if msg=="": break except: break conn.sendall( 'received: ' + msg ) flo.close() conn.close()