2 * $Id: zoomtst7.c,v 1.3 2001-11-06 17:05:19 adam Exp $
11 #include <yaz/xmalloc.h>
16 int main(int argc, char **argv)
20 Z3950_resultset r[10]; /* and result sets .. */
23 o = Z3950_options_create ();
25 for (block = 0; block < 3; block++)
30 printf ("blocking - not calling Z3950_events\n");
33 printf ("blocking - calling Z3950_events\n");
36 printf ("non-blocking - calling Z3950_events\n");
40 Z3950_options_set (o, "async", "1");
41 for (i = 0; i<10; i++)
44 printf ("session %2d", i);
45 sprintf (host, "localhost:9999/%d", i);
46 z = Z3950_connection_create (o);
47 Z3950_connection_connect (z, host, 0);
49 for (j = 0; j < 10; j++)
52 size_t recs_count = 2;
54 Z3950_query s = Z3950_query_create ();
56 sprintf (query, "i%dr%d", i, j);
58 if (Z3950_query_prefix (s, query))
60 printf ("bad PQF: %s\n", query);
63 Z3950_options_set (o, "start", "0");
64 Z3950_options_set (o, "count", "0");
66 r[j] = Z3950_connection_search (z, s); /* non-piggy */
68 Z3950_resultset_records (r[j], recs, 0, 2); /* first two */
70 Z3950_resultset_records (r[j], recs, 1, 2); /* third */
71 Z3950_resultset_records (r[j], recs, 0, 0); /* ignored */
73 if (Z3950_resultset_size (r[j]) > 2)
77 fprintf (stderr, "\nrecord missing\n");
81 Z3950_record_destroy (recs[0]);
82 Z3950_record_destroy (recs[1]);
84 Z3950_query_destroy (s);
88 while (Z3950_event (1, &z))
92 Z3950_resultset_destroy (r[j]);
93 Z3950_connection_destroy (z);
95 Z3950_resultset_destroy (r[j]);
96 printf ("10 searches, 20 presents done\n");
101 Z3950_query q = Z3950_query_create ();
104 printf ("session %2d", i+10);
105 sprintf (host, "localhost:9999/%d", i);
106 z = Z3950_connection_create (o);
107 Z3950_connection_connect (z, host, 0);
109 for (j = 0; j < 10; j++)
113 sprintf (query, "i%dr%d", i, j);
115 Z3950_options_set (o, "count", "0");
117 r[j] = Z3950_connection_search_pqf (z, query);
121 while (Z3950_event (1, &z))
124 Z3950_connection_destroy (z);
126 for (j = 0; j < 10; j++)
128 Z3950_resultset_records (r[j], 0, 0, 1);
130 while (Z3950_event (1, &z))
133 for (j = 0; j < 10; j++)
134 Z3950_resultset_destroy (r[j]);
135 Z3950_query_destroy (q);
136 printf ("10 searches, 10 ignored presents done\n");
139 Z3950_options_destroy (o);