Initial commit
[yaz4j-moved-to-github.git] / dependencies / yaz-2.1.28 / doc / comstack.html
1 <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 10. The COMSTACK Module</title><meta name="generator" content="DocBook XSL Stylesheets V1.70.1"><link rel="start" href="index.html" title="YAZ User's Guide and Reference"><link rel="up" href="index.html" title="YAZ User's Guide and Reference"><link rel="prev" href="odr.debugging.html" title="4. Debugging"><link rel="next" href="comstack.introduction.html" title="2. Introduction"></head><body><link rel="stylesheet" type="text/css" href="common/style1.css"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 10. The COMSTACK Module</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="odr.debugging.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="comstack.introduction.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="comstack"></a>Chapter 10. The COMSTACK Module</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="comstack.html#comstack.synopsis">1. Synopsis (blocking mode)</a></span></dt><dt><span class="sect1"><a href="comstack.introduction.html">2. Introduction</a></span></dt><dt><span class="sect1"><a href="comstack.common.html">3. Common Functions</a></span></dt><dd><dl><dt><span class="sect2"><a href="comstack.common.html#id2606459">3.1. Managing Endpoints</a></span></dt><dt><span class="sect2"><a href="comstack.common.html#id2606615">3.2. Data Exchange</a></span></dt></dl></dd><dt><span class="sect1"><a href="comstack.client.html">4. Client Side</a></span></dt><dt><span class="sect1"><a href="comstack.server.html">5. Server Side</a></span></dt><dt><span class="sect1"><a href="comstack.addresses.html">6. Addresses</a></span></dt><dt><span class="sect1"><a href="comstack.ssl.html">7. SSL</a></span></dt><dt><span class="sect1"><a href="comstack.diagnostics.html">8. Diagnostics</a></span></dt><dt><span class="sect1"><a href="comstack.summary.html">9. Summary and Synopsis</a></span></dt></dl></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="comstack.synopsis"></a>1. Synopsis (blocking mode)</h2></div></div></div><pre class="programlisting">
2     
3 COMSTACK stack;
4 char *buf = 0;
5 int size = 0, length_incoming;
6 char *protocol_package; 
7 int protocol_package_length;
8 char server_address_str[] = "myserver.com:2100";
9 void *server_address_ip;
10 int status;
11
12 stack = cs_create(tcpip_type, 1, PROTO_Z3950);
13 if (!stack) {
14     perror("cs_create");  /* use perror() here since we have no stack yet */
15     exit(1);
16 }
17
18 server_address_ip = cs_addrstr (stack, server_address_str);
19
20 status = cs_connect(stack, server_address_ip);
21 if (status != 0) {
22     cs_perror(stack, "cs_connect");
23     exit(1);
24 }
25
26 status = cs_put(stack, protocol_package, protocol_package_length);
27 if (status) {
28     cs_perror(stack, "cs_put");
29     exit(1);
30 }
31
32 /* Now get a response */
33
34 length_incoming = cs_get(stack, &amp;buf, &amp;size);
35 if (!length_incoming) {
36     fprintf(stderr, "Connection closed\n");
37     exit(1);
38 } else if (length_incoming &lt; 0) {
39     cs_perror(stack, "cs_get");
40     exit(1);
41 }
42
43 /* Do stuff with buf here */
44
45 /* clean up */
46 cs_close(stack);
47 if (buf)
48     free(buf);
49     
50    </pre></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="odr.debugging.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="comstack.introduction.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">4. Debugging </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 2. Introduction</td></tr></table></div></body></html>