1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2008 Index Data
3 * See the file LICENSE for details.
11 void probe_package(ZOOM_connection z)
14 for (i = 1; i<10; i++)
16 ZOOM_package pkg = ZOOM_connection_package(z, 0);
17 ZOOM_package_option_set(pkg, "action", "recordInsert");
18 ZOOM_package_option_set(pkg, "record", "1234");
19 ZOOM_package_send(pkg, "update");
23 void probe_search(ZOOM_connection z, int start, int error)
28 /* provoke error with yaz-ztest */
30 ZOOM_connection_option_set(z, "databaseName", "x");
32 sprintf(pqf_str, "@attr 1=%d water", start);
33 printf("sending search %s\n", pqf_str);
34 set = ZOOM_connection_search_pqf (z, pqf_str);
35 ZOOM_resultset_destroy(set);
37 /* restore database */
39 ZOOM_connection_option_set(z, "databaseName", "Default");
42 int main(int argc, char **argv)
47 const char *errmsg, *addinfo, *diagset;
51 fprintf (stderr, "usage:\n%s target\n", *argv);
53 "Verify: asynchronous single-target client\n");
57 /* create connection (don't connect yet) */
58 z = ZOOM_connection_create(0);
60 /* option: set sru/get operation (only applicable if http: is used) */
61 ZOOM_connection_option_set (z, "sru", "post");
63 /* option: set async operation */
64 ZOOM_connection_option_set (z, "async", "1");
66 /* connect to target and initialize */
67 ZOOM_connection_connect (z, argv[1], 0);
69 probe_search(z, use, 1);
71 /* block here: only one connection */
72 while (ZOOM_event (1, &z))
74 int ev = ZOOM_connection_last_event(z);
75 int idle = ZOOM_connection_is_idle(z);
77 /* see if any error occurred */
78 if ((error = ZOOM_connection_error_x(z, &errmsg, &addinfo, &diagset)))
80 fprintf (stderr, "Error: %s: %s (%d) %s\n", diagset, errmsg, error,
84 if (ev == ZOOM_EVENT_RECV_SEARCH)
87 printf ("Search OK\n");
88 printf("idle=%d\n", idle);
92 ZOOM_connection_connect(z, 0, 0); /* allow reconnect */
96 probe_search(z, use, use&1);
98 printf("Press enter\n");
102 ZOOM_connection_destroy (z);
108 * indent-tabs-mode: nil
110 * vim: shiftwidth=4 tabstop=8 expandtab