1# 2# Copyright (C) 1997-2000 Matt Newman <matt@novadigm.com> 3# 4# $Header: /cvsroot/tls/tls/tests/oldTests/tlsAuto.tcl,v 1.1 2000/06/06 18:13:20 aborr Exp $ 5# 6 7set dir [file dirname [info script]] 8cd $dir 9source tls.tcl 10 11proc fromServer {chan} { 12 if {[catch {read $chan 10} data]} { 13 catch {close $chan} 14 tclLog "EOF ($data)" 15 set ::/Exit 1 16 return 17 } 18 if {[eof $chan]} { 19 close $chan 20 set ::/Exit 1 21 } 22 if {$data != ""} { 23 puts -nonewline stderr "$data" 24 } 25} 26proc doit {chan count {delay 1000}} { 27 if {$count == 0} { 28 close $chan 29 set ::/Exit 0 30 return 31 } 32 puts $chan line$count 33 flush $chan 34 35 incr count -1 36 after $delay doit $chan $count $delay 37} 38array set opts { 39 -port 1234 40 -host localhost 41} 42array set opts $argv 43# 44# Initialize context 45# 46#tls::init -certfile client.pem -cafile server.pem ;#-cipher RC4-MD5 47tls::init 48# 49# Create socket and import SSL layer 50# 51#set chan [tls::socket -async -request 0 $opts(-host) $opts(-port)] 52set chan [tls::socket -request 0 $opts(-host) $opts(-port)] 53 54fconfigure $chan -buffering none -blocking 0 -translation binary 55fileevent $chan readable [list fromServer $chan] 56 57doit $chan 1000 100 58vwait /Exit 59