Пример #1
0
def do_handshake_socket(ctx, host, port):
    s = socket.socket()
    s.connect((host, port))

    def send_func(buf):
        s.sendall(buf)

    def recv_func(n=0):
        ret = s.recv(16 * 1024)
        return ret

    try:
        tls.do_handshake(ctx, send_func, recv_func)
    finally:
        s.close()
Пример #2
0
def do_handshake_socket(ctx, host, port):
    s = socket.socket()
    s.connect((host, port))

    def send_func(buf):
        print '>>>', buf.encode('hex')
        s.sendall(buf)

    def recv_func(n=0):
        ret = s.recv(16*1024)
        print '<<<', ret.encode('hex')
        return ret

    try:
        tls.do_handshake(ctx, send_func, recv_func)
    finally:
        s.close()