Import of old SSLeay release: SSLeay 0.9.1b (unreleased)
[openssl.git] / perl / bio.pl
1 #!/usr/local/bin/perl
2
3 use ExtUtils::testlib;
4
5 use SSLeay;
6
7 $cmd=<<"EOF";
8 GET / HTTP/1.0
9
10 EOF
11
12 $conn="localhost:4433";
13 $conn=$ARGV[0] if $#ARGV >= 0;
14 $bio=SSLeay::BIO::new("connect");
15 #$bio->set_callback(sub {print STDERR SSLeay::BIO::number_read($_[0])."\n"; $_[$#_] });
16 #$bio->set_callback(sub {print STDERR "$#_:".$_[0].":$_[1]:$_[2]:$_[3]:$_[4]:\n"; $_[$#_] });
17 $bio->hostname($conn) || die $ssl->error();
18
19
20 (($ret=$bio->do_handshake()) > 0) || die $bio->error();
21
22 (($ret=$bio->syswrite($cmd)) > 0) || die $bio->error();
23
24 while (1)
25         {
26         $ret=$bio->sysread($buf,10240);
27         last if ($ret <= 0);
28         print $buf;
29         }
30