Initial commit
[yaz4j-moved-to-github.git] / dependencies / yaz-2.1.28 / doc / comstack.server.html
1 <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>5. Server Side</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="comstack.html" title="Chapter 10. The COMSTACK Module"><link rel="prev" href="comstack.client.html" title="4. Client Side"><link rel="next" href="comstack.addresses.html" title="6. Addresses"></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">5. Server Side</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="comstack.client.html">Prev</a> </td><th width="60%" align="center">Chapter 10. The COMSTACK Module</th><td width="20%" align="right"> <a accesskey="n" href="comstack.addresses.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="comstack.server"></a>5. Server Side</h2></div></div></div><p>
2     To establish a server under the <span class="application">inetd</span>
3     server, you can use
4    </p><pre class="synopsis">
5     COMSTACK cs_createbysocket(int socket, CS_TYPE type, int blocking,
6                                int protocol);
7    </pre><p>
8     The <code class="literal">socket</code> parameter is an established socket (when
9     your application is invoked from <span class="application">inetd</span>, the
10     socket will typically be 0.
11     The following parameters are identical to the ones for
12     <code class="function">cs_create</code>.
13    </p><pre class="synopsis">
14     int cs_bind(COMSTACK handle, void *address, int mode)
15    </pre><p>
16     Binds a local address to the endpoint. Read about addresses below. The
17     <code class="literal">mode</code> parameter should be either
18     <code class="literal">CS_CLIENT</code> or <code class="literal">CS_SERVER</code>.
19    </p><pre class="synopsis">
20     int cs_listen(COMSTACK handle, char *addr, int *addrlen);
21    </pre><p>
22     Call this to process incoming events on an endpoint that has been
23     bound in listening mode. It will return 0 to indicate that the connect
24     request has been received, 1 to signal a partial reception, and -1 to
25     indicate an error condition.
26    </p><pre class="synopsis">
27     COMSTACK cs_accept(COMSTACK handle);
28    </pre><p>
29     This finalizes the server-side association establishment, after
30     cs_listen has completed successfully. It returns a new connection
31     endpoint, which represents the new association. The application will
32     typically wish to fork off a process to handle the association at this
33     point, and continue listen for new connections on the old
34     <code class="literal">handle</code>.
35    </p><p>
36     You can use the call
37    </p><pre class="synopsis">
38     char *cs_addrstr(COMSTACK);
39    </pre><p>
40     on an established connection to retrieve the host-name of the remote host.
41    </p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>You may need to use this function with some care if your
42      name server service is slow or unreliable
43     </p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="comstack.client.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="comstack.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="comstack.addresses.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">4. Client Side </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 6. Addresses</td></tr></table></div></body></html>