2 * $Id: zoomtst8.c,v 1.1 2001-12-30 22:21:11 adam Exp $
4 * Asynchronous multi-target client doing scan
11 #include <yaz/xmalloc.h>
14 int main(int argc, char **argv)
18 ZOOM_connection z[500]; /* allow at most 500 connections */
19 ZOOM_scanset s[500]; /* and scan sets .. */
20 ZOOM_options o = ZOOM_options_create ();
24 fprintf (stderr, "usage:\n%s target1 target2 ... targetN scan\n",
32 ZOOM_options_set (o, "async", "1");
35 for (i = 0; i<no; i++)
37 /* create connection - pass options (they are the same for all) */
38 z[i] = ZOOM_connection_create (o);
40 /* connect and init */
41 ZOOM_connection_connect (z[i], argv[1+i], 0);
44 for (i = 0; i<no; i++)
45 s[i] = ZOOM_connection_scan (z[i], argv[argc-1]);
47 /* network I/O. pass number of connections and array of connections */
48 while (ZOOM_event (no, z))
51 for (i = 0; i<no; i++)
54 const char *errmsg, *addinfo;
55 if ((error = ZOOM_connection_error(z[i], &errmsg, &addinfo)))
56 fprintf (stderr, "%s error: %s (%d) %s\n",
57 ZOOM_connection_option_get(z[i], "host"),
58 errmsg, error, addinfo);
62 printf ("%s\n", ZOOM_connection_option_get(z[i], "host"));
63 for (j = 0; j<ZOOM_scanset_size (s[i]); j++)
67 term = ZOOM_scanset_term (s[i], j, &occur, &len);
69 printf ("%d %.*s %d\n", j, len, term, occur);
75 /* destroy and exit */
76 for (i = 0; i<no; i++)
78 ZOOM_scanset_destroy (s[i]);
79 ZOOM_connection_destroy (z[i]);
81 ZOOM_options_destroy(o);