""" client.py see http://docs.python.org/howto/sockets.html and http://docs.python.org/library/socket.html Jim Mahoney | Fall 2012 | Marlboro College """ import socket import time host = 'thirty-two' buffer_size = 1024 port = 10003 sock = socket.socket() print "opening connection to %s" % str((host, port)) print "" sock.connect((host, port)) for message_id in ('one', 'two'): message = 'message %s sent at %s' % (message_id, time.asctime()) print "sending : %s" % message sock.sendall(message) data = sock.recv(buffer_size) print "server sent: %s" % str(data) print "" print "closing connection" sock.close()