def main():
    global opts
    opts = ttls.parseopt(1)
    port = opts.port
    host = opts.host

    # a spki socket
    sock = sexpsocket.socket(sexpsocket.AF_INET,
                             sexpsocket.SOCK_STREAM)  
    sock.connect((host, port))
    sess = ttls.Session(sock, 1)

    if not do_handshake(sess):
        print "handshake failed"
        return
    sess.makeKeys()
    for i in range(128):
	sess.send('Message #%d' % i)
	buf = None
	while buf is None:
	    buf = sess.recv()
	print `buf`
    sess.close()
def main():
    opts = ttls.parseopt(0)
    server = MyServer((opts.host, opts.port), TTLSRequestHandler,
                      opts.getKeyPair(), opts) 
    server.serve_forever()