2 * $Id: zoomtst7.c,v 1.4 2001-11-11 22:25:25 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 z = Z3950_connection_new ("localhost", 9999);
26 if (Z3950_connection_error (z, 0, 0))
28 printf ("error - couldn't connect?\n");
32 Z3950_connection_destroy (z);
34 for (block = 0; block < 3; block++)
39 printf ("blocking - not calling Z3950_events\n");
42 printf ("blocking - calling Z3950_events\n");
45 printf ("non-blocking - calling Z3950_events\n");
49 Z3950_options_set (o, "async", "1");
50 for (i = 0; i<10; i++)
53 printf ("session %2d", i);
54 sprintf (host, "localhost:9999/%d", i);
55 z = Z3950_connection_create (o);
56 Z3950_connection_connect (z, host, 0);
58 for (j = 0; j < 10; j++)
61 size_t recs_count = 2;
63 Z3950_query s = Z3950_query_create ();
65 sprintf (query, "i%dr%d", i, j);
67 if (Z3950_query_prefix (s, query))
69 printf ("bad PQF: %s\n", query);
72 Z3950_options_set (o, "start", "0");
73 Z3950_options_set (o, "count", "0");
75 r[j] = Z3950_connection_search (z, s); /* non-piggy */
77 Z3950_resultset_records (r[j], recs, 0, 2); /* first two */
79 Z3950_resultset_records (r[j], recs, 1, 2); /* third */
80 Z3950_resultset_records (r[j], recs, 0, 0); /* ignored */
82 if (Z3950_resultset_size (r[j]) > 2)
86 fprintf (stderr, "\nrecord missing\n");
90 Z3950_record_destroy (recs[0]);
91 Z3950_record_destroy (recs[1]);
93 Z3950_query_destroy (s);
97 while (Z3950_event (1, &z))
100 for (j = 0; j<i; j++)
101 Z3950_resultset_destroy (r[j]);
102 Z3950_connection_destroy (z);
104 Z3950_resultset_destroy (r[j]);
105 printf ("10 searches, 20 presents done\n");
108 for (i = 0; i<1; i++)
110 Z3950_query q = Z3950_query_create ();
113 printf ("session %2d", i+10);
114 sprintf (host, "localhost:9999/%d", i);
115 z = Z3950_connection_create (o);
116 Z3950_connection_connect (z, host, 0);
118 for (j = 0; j < 10; j++)
122 sprintf (query, "i%dr%d", i, j);
124 Z3950_options_set (o, "count", "0");
126 r[j] = Z3950_connection_search_pqf (z, query);
130 while (Z3950_event (1, &z))
133 Z3950_connection_destroy (z);
135 for (j = 0; j < 10; j++)
137 Z3950_resultset_records (r[j], 0, 0, 1);
139 while (Z3950_event (1, &z))
142 for (j = 0; j < 10; j++)
143 Z3950_resultset_destroy (r[j]);
144 Z3950_query_destroy (q);
145 printf ("10 searches, 10 ignored presents done\n");
148 Z3950_options_destroy (o);