from socket import * # get constructor and constants HOST = '' # symbolic name of the local host PORT = 50007 # arbitrary non-privileged server s = socket(AF_INET, SOCK_STREAM) s.bind((HOST, PORT)) s.listen(1) conn, addr = s.accept() print 'Connected by', addr while 1: data = conn.recv(1024) # use connected socket if not data: break # repeat accept for > 1 client conn.send(data) conn.close()