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