source: python/TLSLite/shared/client.py @ 29

Revision 29, 735 bytes checked in by nakiki, 13 years ago (diff)
  • Property svn:executable set to *
Line 
1#!/usr/bin/python
2# -*- coding: utf-8 -*-
3
4import socket
5import tlslite.api as tls
6import sys
7
8DST = ('localhost', 3747)
9
10# 証明書を使った場合の例
11def connect(sockaddr):
12  sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
13  sock.connect(sockaddr)
14  sock.settimeout(10)
15  conn = tls.TLSConnection(sock)
16  conn.closeSocket = True
17  conn.handshakeClientSharedKey(username = 'nakiki', sharedKey = 'nakikinakiki')
18  return conn
19
20conn = connect(DST)
21rfile = conn.makefile('rb')
22while 1:
23  print '> ',
24  line = sys.stdin.readline()
25  if len(line) == 0:
26    conn.close()
27    print
28    break
29  conn.write(line)
30  line = rfile.readline()
31  if len(line) == 0:
32    conn.close()
33    print 'EOF'
34    break
35  sys.stdout.write(line)
Note: See TracBrowser for help on using the repository browser.