From 8fd9afc1ae5f689bd1fcb9427155ca258e79bb59 Mon Sep 17 00:00:00 2001 From: mike Date: Tue, 11 Apr 2006 16:13:45 +0000 Subject: [PATCH] The shortest and simplest possible asynchronous application. Omits all error checking, so never use this in real life! --- samples/zoom/trivial-async.pl | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 samples/zoom/trivial-async.pl diff --git a/samples/zoom/trivial-async.pl b/samples/zoom/trivial-async.pl new file mode 100644 index 0000000..6dcb41e --- /dev/null +++ b/samples/zoom/trivial-async.pl @@ -0,0 +1,22 @@ +use ZOOM; +@targets = ('z3950.loc.gov:7090/Voyager', + 'bagel.indexdata.com:210/gils'); +$o = new ZOOM::Options(); +$o->option(async => 1); # asynchronous mode +$o->option(count => 1); # piggyback retrieval count +$o->option(preferredRecordSyntax => "usmarc"); +for ($i = 0; $i < @targets; $i++) { + $z[$i] = create ZOOM::Connection($o); + $z[$i]->connect($targets[$i]); + $r[$i] = $z[$i]->search_pqf("mineral"); +} +while (($i = ZOOM::event(\@z)) != 0) { + $ev = $z[$i-1]->last_event(); + print("connection ", $i-1, ": ", ZOOM::event_str($ev), "\n"); + if ($ev == ZOOM::Event::ZEND) { + $size = $r[$i-1]->size(); + print "connection ", $i-1, ": $size hits\n"; + print $r[$i-1]->record(0)->render() + if $size > 0; + } +} -- 1.7.10.4