xtrans.xml revision e45ace2b
1af928962Smrg<?xml version="1.0" encoding="UTF-8" ?>
2af928962Smrg<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
3fe567363Smrg                      "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"
4fe567363Smrg[
5fe567363Smrg<!ENTITY % defs SYSTEM "defs.ent"> %defs;
6fe567363Smrg]>
7af928962Smrg
8af928962Smrg<!-- lifted from troff+ms+XMan by doclifter -->
9af928962Smrg<book id="xtrans">
10af928962Smrg
11af928962Smrg<bookinfo>
12af928962Smrg   <title>X Transport Interface</title>
13af928962Smrg   <subtitle>X Consortium Standard</subtitle>
14af928962Smrg   <authorgroup>
15fe567363Smrg     <author>
16fe567363Smrg       <firstname>Stuart</firstname><surname>Anderson</surname>
17fe567363Smrg       <affiliation><orgname>NCR Corporation</orgname></affiliation>
18fe567363Smrg     </author>
19fe567363Smrg     <othercredit><firstname>Ralph</firstname><surname>Mor</surname>
20fe567363Smrg       <affiliation><orgname>X Consortium</orgname></affiliation>
21fe567363Smrg     </othercredit>
22fe567363Smrg     <othercredit><firstname>Alan</firstname><surname>Coopersmith</surname>
23fe567363Smrg       <affiliation><orgname>Oracle Corp.</orgname></affiliation>
24fe567363Smrg     </othercredit>
25af928962Smrg   </authorgroup>
26fe567363Smrg   <releaseinfo>X Version 11, Release &fullrelvers;</releaseinfo>
2775ebec6dSmrg   <releaseinfo>Version 1.2</releaseinfo>
28fe567363Smrg   <copyright><year>1993</year><year>1994</year>
29fe567363Smrg     <holder>NCR Corporation - Dayton, Ohio, USA</holder>
30fe567363Smrg   </copyright>
31af928962Smrg
32af928962Smrg<legalnotice>
33af928962Smrg<para>
34af928962SmrgAll Rights Reserved
35af928962Smrg</para>
36af928962Smrg<para>
37af928962SmrgPermission to use, copy, modify, and distribute this software and its
38af928962Smrgdocumentation for any purpose and without fee is hereby granted, provided
39af928962Smrgthat the above copyright notice appear in all copies and that both that
40af928962Smrgcopyright notice and this permission notice appear in supporting
41af928962Smrgdocumentation, and that the name NCR not be used in advertising
42af928962Smrgor publicity pertaining to distribution of the software without specific,
43af928962Smrgwritten prior permission.  NCR makes no representations about the
44af928962Smrgsuitability of this software for any purpose.  It is provided "as is"
45af928962Smrgwithout express or implied warranty.
46af928962Smrg</para>
47af928962Smrg<para>
48af928962SmrgNCR DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
49af928962SmrgINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
50af928962SmrgNO EVENT SHALL NCR BE LIABLE FOR ANY SPECIAL, INDIRECT OR
51af928962SmrgCONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
52af928962SmrgOF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
53af928962SmrgNEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
54af928962SmrgCONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
55af928962Smrg</para>
56af928962Smrg</legalnotice>
57af928962Smrg
58af928962Smrg<legalnotice>
59fe567363Smrg<para role="multiLicensing">
60af928962SmrgCopyright &copy; 1993, 1994, 2002 The Open Group
61af928962Smrg</para>
62af928962Smrg<para>
63af928962SmrgPermission is hereby granted, free of charge, to any person obtaining a copy
64af928962Smrgof this software and associated documentation files (the &ldquo;Software&rdquo;), to deal
65af928962Smrgin the Software without restriction, including without limitation the rights
66af928962Smrgto use, copy, modify, merge, publish, distribute, sublicense, and/or sell
67af928962Smrgcopies of the Software, and to permit persons to whom the Software is
68af928962Smrgfurnished to do so, subject to the following conditions:
69af928962Smrg</para>
70af928962Smrg<para>
71af928962SmrgThe above copyright notice and this permission notice shall be included in
72af928962Smrgall copies or substantial portions of the Software.
73af928962Smrg</para>
74af928962Smrg<para>
75af928962SmrgTHE SOFTWARE IS PROVIDED &ldquo;AS IS&rdquo;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
76af928962SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
77af928962SmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
78af928962SmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
79af928962SmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
80af928962SmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
81af928962Smrg</para>
82af928962Smrg<para>
83af928962SmrgExcept as contained in this notice, the name of The Open Group shall not be
84af928962Smrgused in advertising or otherwise to promote the sale, use or other dealings
85af928962Smrgin this Software without prior written authorization from The Open Group.
86af928962Smrg</para>
87af928962Smrg<para>
88af928962SmrgX Window System is a trademark of The Open Group, Inc.
89af928962Smrg</para>
90af928962Smrg</legalnotice>
91af928962Smrg</bookinfo>
92af928962Smrg
93af928962Smrg<preface><title>The X Transport Interface</title>
94af928962Smrg<para>
95af928962SmrgDesigned by Stuart Anderson (NCR) with help from Ralph Mor (X Consortium)
96af928962Smrg</para>
97af928962Smrg
98af928962Smrg<note><para>
99af928962SmrgThis documentation does not completely match the implementation in R6
100af928962Smrg(as a result of some late changes made in the code). Specifically, support
101af928962Smrgwas added for font server cloning, and conditional compliation was introduced
102af928962Smrgfor client vs. server code.
103af928962Smrg</para></note>
104af928962Smrg</preface>
105af928962Smrg
106fe567363Smrg<chapter id='Purposes_and_Goals'>
107af928962Smrg<title>Purposes and Goals</title>
108af928962Smrg
109af928962Smrg<para>The X Transport Interface is intended to combine all system and
110af928962Smrgtransport specific code into a single place in the source tree. This API
111af928962Smrgshould be used by all libraries, clients and servers of the X Window System.
112af928962SmrgUse of this API should allow the addition of new types of transports and
113af928962Smrgsupport for new platforms without making any changes to the source except
114af928962Smrgin the X Transport Interface code.</para>
115af928962Smrg<para>This interface should solve the problem of multiple
116af928962Smrg<code>#ifdef TRANSPORT</code> and <code>#ifdef PLATFORM</code>
117af928962Smrgstatements scattered throughout the source tree.</para>
118af928962Smrg<para>This interface should provide enough functionality to support all
119af928962Smrgtypes of protocols, including connection oriented protocols such as X11 and
120af928962SmrgFS, and connection-less oriented protocols such as XDMCP.</para>
121af928962Smrg
122af928962Smrg</chapter>
123af928962Smrg
124fe567363Smrg<chapter id='Overview_of_the_Interface'>
125af928962Smrg<title>Overview of the Interface</title>
126af928962Smrg
127af928962Smrg<para>
128af928962SmrgThe interface provides an API for use by applications. The functions in
129af928962Smrgthis API perform work that is common to all transports and systems, such
130af928962Smrgas parsing an address into a host and port number. The functions in this
131af928962SmrgAPI call transport specific functions that are contained in a table whose
132af928962Smrgcontents are defined at compile time. This table contains an entry for each
133af928962Smrgtype of transport. Each entry is a record containing mostly pointers to
134af928962Smrgfunction that implements the interface for the given transport.
135af928962Smrg</para>
136af928962Smrg<para>
137af928962SmrgThis API does not provide an abstraction for <function>select()</function>
138af928962Smrgor <function>poll()</function>.
139af928962SmrgThese functions are themselves transport independent, so an additional
140af928962Smrginterface is not needed for these functions. It is also unclear how such
141af928962Smrgan interface would affect performance.
142af928962Smrg</para>
143af928962Smrg</chapter>
144af928962Smrg
145fe567363Smrg<chapter id='Definition_of_Address_Specification_Format'>
146af928962Smrg<title>Definition of Address Specification Format</title>
147af928962Smrg
148af928962Smrg<para>
149af928962SmrgAddresses are specified in the following syntax,
150af928962Smrg
151af928962Smrg<synopsis>
152af928962Smrg<replaceable>protocol</replaceable>/<replaceable>host</replaceable>:<replaceable>port</replaceable>
153af928962Smrg</synopsis>
154af928962Smrg
155af928962Smrgwhere <replaceable>protocol</replaceable> specifies a protocol family
156af928962Smrgor an alias for a protocol family. A definition of common protocol
157af928962Smrgfamilies is given in a later section.
158af928962Smrg</para>
159af928962Smrg<para>
160af928962SmrgThe <replaceable>host</replaceable> part specifies the name of a host or other
161af928962Smrgtransport dependent entity that could be interpreted as a Network Service Access Point
162af928962Smrg(NSAP).
163af928962Smrg</para>
164af928962Smrg<para>
165af928962SmrgThe <replaceable>port</replaceable> part specifies the name of a Transport Service
166af928962SmrgAccess Point (TSAP). The format of the TSAP is defined by the underlying transport
167af928962Smrgimplementation, but it is represented using a string format when it is
168af928962Smrgpart of an address.
169af928962Smrg</para>
170af928962Smrg</chapter>
171af928962Smrg
172fe567363Smrg<chapter id='Internal_Data_Structures'>
173af928962Smrg<title>Internal Data Structures</title>
174af928962Smrg<para>
175af928962SmrgThere are two major data structures associated with the transport
176af928962Smrgindependent portion of this interface.  Additional data structures
177af928962Smrgmay be used internally by each transport.
178af928962Smrg</para>
179fe567363Smrg<sect1 id='Xtransport'>
180af928962Smrg<title>Xtransport</title>
181af928962Smrg<para>
182af928962SmrgEach transport supported has an entry in the transport table. The transport
183af928962Smrgtable is an array of Xtransport records. Each record contains all the entry
184af928962Smrgpoints for a single transport. This record is defined as:
185af928962Smrg</para>
186af928962Smrg
187af928962Smrg<synopsis>
188af928962Smrgtypedef struct _Xtransport {
189af928962Smrg
1906a3641a6Ssnj    const char *TransName;
191af928962Smrg    int  flags;
192af928962Smrg
193af928962Smrg    XtransConnInfo (*OpenCOTSClient)(
1946a3641a6Ssnj     struct _Xtransport *,    /* transport */
1956a3641a6Ssnj     const char *,            /* protocol */
1966a3641a6Ssnj     const char *,            /* host */
1976a3641a6Ssnj     const char *             /* port */
198af928962Smrg    );
199af928962Smrg
200af928962Smrg    XtransConnInfo (*OpenCOTSServer)(
2016a3641a6Ssnj     struct _Xtransport *,    /* transport */
2026a3641a6Ssnj     const char *,            /* protocol */
2036a3641a6Ssnj     const char *,            /* host */
2046a3641a6Ssnj     const char *             /* port */
205af928962Smrg    );
206af928962Smrg
207af928962Smrg    int     (*SetOption)(
208af928962Smrg     XtransConnInfo,          /* connection */
209af928962Smrg     int,               /* option */
210af928962Smrg     int               /* arg */
211af928962Smrg    );
212af928962Smrg
213af928962Smrg    int     (*CreateListener)(
214af928962Smrg     XtransConnInfo,          /* connection */
2156a3641a6Ssnj     const char *,            /* port */
2166a3641a6Ssnj     int                      /* flags */
217af928962Smrg    );
218af928962Smrg
219af928962Smrg    int     (*ResetListener)(
220af928962Smrg     XtransConnInfo          /* connection */
221af928962Smrg    );
222af928962Smrg
223af928962Smrg    XtransConnInfo (*Accept)(
224af928962Smrg     XtransConnInfo          /* connection */
225af928962Smrg    );
226af928962Smrg
227af928962Smrg    int     (*Connect)(
228af928962Smrg     XtransConnInfo,          /* connection */
2296a3641a6Ssnj     const char *,            /* host */
2306a3641a6Ssnj     const char *             /* port */
231af928962Smrg    );
232af928962Smrg
233af928962Smrg    int     (*BytesReadable)(
234af928962Smrg     XtransConnInfo,          /* connection */
235af928962Smrg     BytesReadable_t *     /* pend */
236af928962Smrg    );
237af928962Smrg
238af928962Smrg    int     (*Read)(
239af928962Smrg     XtransConnInfo,          /* connection */
240af928962Smrg     char *,               /* buf */
241af928962Smrg     int               /* size */
242af928962Smrg    );
243af928962Smrg
244af928962Smrg    int     (*Write)(
245af928962Smrg     XtransConnInfo,          /* connection */
246af928962Smrg     char *,               /* buf */
247af928962Smrg     int               /* size */
248af928962Smrg    );
249af928962Smrg
250af928962Smrg    int     (*Readv)(
251af928962Smrg     XtransConnInfo,          /* connection */
252af928962Smrg     struct iovec *,          /* buf */
253af928962Smrg     int               /* size */
254af928962Smrg    );
255af928962Smrg
256af928962Smrg    int     (*Writev)(
257af928962Smrg     XtransConnInfo,          /* connection */
258af928962Smrg     struct iovec *,          /* buf */
259af928962Smrg     int               /* size */
260af928962Smrg    );
261af928962Smrg
262af928962Smrg    int     (*Disconnect)(
263af928962Smrg     XtransConnInfo          /* connection */
264af928962Smrg    );
265af928962Smrg
266af928962Smrg    int     (*Close)(
267af928962Smrg     XtransConnInfo          /* connection */
268af928962Smrg    );
269af928962Smrg
270af928962Smrg} Xtransport;
271af928962Smrg</synopsis>
272af928962Smrg
273af928962Smrg<para>
274af928962SmrgThe <structfield>flags</structfield> field can contain an OR of
275af928962Smrgthe following masks:
276af928962Smrg<variablelist>
277af928962Smrg  <varlistentry>
278af928962Smrg    <term><symbol>TRANS_ALIAS</symbol></term>
279af928962Smrg    <listitem><para>
280af928962Smrgindicates that this record is providing an alias, and should
281af928962Smrgnot be used to create a listener.
282af928962Smrg      </para></listitem>
283af928962Smrg  </varlistentry>
284af928962Smrg  <varlistentry>
285af928962Smrg    <term><symbol>TRANS_LOCAL</symbol></term>
286af928962Smrg    <listitem><para>
287af928962Smrgindicates that this is a <symbol>LOCALCONN</symbol> transport.
288af928962Smrg    </para></listitem>
289af928962Smrg  </varlistentry>
290af928962Smrg  <varlistentry>
291af928962Smrg    <term><symbol>TRANS_ABSTRACT</symbol></term>
292af928962Smrg    <listitem><para>
293af928962Smrgindicates that a local connection transport uses the abstract socket namespace.
294af928962Smrg    </para></listitem>
295af928962Smrg  </varlistentry>
296af928962Smrg</variablelist>
297af928962Smrg</para>
298af928962Smrg
299af928962Smrg<para>
300af928962SmrgSome additional flags may be set in the <structfield>flags</structfield>
301af928962Smrgfield by the library while it is running:
302af928962Smrg<variablelist>
303af928962Smrg  <varlistentry>
304af928962Smrg    <term><symbol>TRANS_DISABLED</symbol></term>
305af928962Smrg    <listitem><para>
306af928962Smrgindicates that this transport has been disabled.
307af928962Smrg    </para></listitem>
308af928962Smrg  </varlistentry>
309af928962Smrg  <varlistentry>
310af928962Smrg    <term><symbol>TRANS_NOLISTEN</symbol></term>
311af928962Smrg    <listitem><para>
312af928962Smrgindicates that servers should not open new listeners using this transport.
313af928962Smrg    </para></listitem>
314af928962Smrg  </varlistentry>
315af928962Smrg  <varlistentry>
316af928962Smrg    <term><symbol>TRANS_NOUNLINK</symbol></term>
317af928962Smrg    <listitem><para>
318af928962Smrgset by a transport backend to indicate that the endpoints for its connection
319af928962Smrgshould not be unlinked.
320af928962Smrg    </para></listitem>
321af928962Smrg  </varlistentry>
322af928962Smrg</variablelist>
323af928962Smrg</para>
324af928962Smrg</sect1>
325af928962Smrg
326fe567363Smrg<sect1 id='XtransConnInfo'>
327af928962Smrg<title>XtransConnInfo</title>
328af928962Smrg<para>
329af928962SmrgEach connection will have an opaque <structname>XtransConnInfo</structname>
330af928962Smrgtransport connection
331af928962Smrgobject allocated for it. This record contains information specific to the
332af928962Smrgconnection. The record is defined as:
333af928962Smrg
334af928962Smrg<synopsis>
335af928962Smrgtypedef struct _XtransConnInfo *XtransConnInfo;
336af928962Smrg
337af928962Smrgstruct _XtransConnInfo {
338af928962Smrg    struct _Xtransport     *transptr;
339af928962Smrg    char     *priv;
340af928962Smrg    int          flags;
341af928962Smrg    int          fd;
342af928962Smrg    int          family;
343af928962Smrg    char     *addr;
344af928962Smrg    int          addrlen;
345af928962Smrg    char     *peeraddr;
346af928962Smrg    int          peeraddrlen;
347af928962Smrg};
348af928962Smrg</synopsis>
349af928962Smrg</para>
350af928962Smrg</sect1>
351af928962Smrg</chapter>
352af928962Smrg
353fe567363Smrg<chapter id='Exposed_Transport_Independent_API'>
354af928962Smrg<title>Exposed Transport Independent API</title>
355af928962Smrg
356af928962Smrg<para>
357af928962SmrgThis API is included in each library and server that uses it. The API may
358af928962Smrgbe used by the library, but it is not added to the public API for that
359af928962Smrglibrary. This interface is simply an implementation facilitator. This API
360af928962Smrgcontains a low level set of core primitives, and a few utility functions
361af928962Smrgthat are built on top of the primitives.  The utility functions exist to
362af928962Smrgprovide a more familiar interface that can be used to port existing code.
363af928962Smrg</para>
364af928962Smrg<para>
365af928962SmrgA macro is defined in Xtrans.h for TRANS(func) that creates a unique function
366af928962Smrgname depending on where the code is compiled. For example, when built for
36775ebec6dSmrgXlib, <function>TRANS(OpenCOTSClient)</function> becomes
36875ebec6dSmrg<function>_X11TransOpenCOTSClient</function>.
369af928962Smrg</para>
370af928962Smrg<para>
371af928962SmrgAll failures are considered fatal, and the connection should be closed
372af928962Smrgand re-established if desired. In most cases, however, the value of
373af928962Smrgerrno will be available for debugging purposes.
374af928962Smrg</para>
375fe567363Smrg<sect1 id='Core_Interface_API'>
376af928962Smrg<title>Core Interface API</title>
377af928962Smrg<itemizedlist mark='bullet'>
378af928962Smrg  <listitem>
37975ebec6dSmrg    <funcsynopsis id='TRANSOpenCOTSClient'>
38075ebec6dSmrg      <funcprototype>
38175ebec6dSmrg        <funcdef>XtransConnInfo <function>TRANS(OpenCOTSClient)</function></funcdef>
3826a3641a6Ssnj        <paramdef>const char *<parameter>address</parameter></paramdef>
38375ebec6dSmrg      </funcprototype>
38475ebec6dSmrg    </funcsynopsis>
385af928962Smrg    <para>
386af928962SmrgThis function creates a Connection-Oriented Transport that is
387af928962Smrgsuitable for use by a client. The parameter <parameter>address</parameter>
38875ebec6dSmrgcontains the full address of the server to which this endpoint will be
38975ebec6dSmrgconnected.  This function returns an opaque transport connection object on
39075ebec6dSmrgsuccess, or <constant>NULL</constant> on failure.
391af928962Smrg    </para>
392af928962Smrg  </listitem>
393af928962Smrg  <listitem>
39475ebec6dSmrg    <funcsynopsis id='TRANSOpenCOTSServer'>
39575ebec6dSmrg      <funcprototype>
39675ebec6dSmrg        <funcdef>XtransConnInfo <function>TRANS(OpenCOTSServer)</function></funcdef>
3976a3641a6Ssnj        <paramdef>const char *<parameter>address</parameter></paramdef>
39875ebec6dSmrg      </funcprototype>
39975ebec6dSmrg    </funcsynopsis>
400af928962Smrg    <para>
401af928962SmrgThis function creates a Connection-Oriented Transport that is suitable
402af928962Smrgfor use by a server. The parameter <parameter>address</parameter> contains the
40375ebec6dSmrgfull address to which this server will be bound. This function returns an
40475ebec6dSmrgopaque transport connection object on success, or <constant>NULL</constant>
40575ebec6dSmrgon failure.
406af928962Smrg    </para>
407af928962Smrg  </listitem>
408af928962Smrg  <listitem>
40975ebec6dSmrg    <funcsynopsis id='TRANSSetOption'>
41075ebec6dSmrg      <funcprototype>
41175ebec6dSmrg        <funcdef>int <function>TRANS(SetOption)</function></funcdef>
41275ebec6dSmrg        <paramdef>XtransConnInfo <parameter>connection</parameter></paramdef>
41375ebec6dSmrg        <paramdef>int <parameter>option</parameter></paramdef>
41475ebec6dSmrg        <paramdef>int <parameter>arg</parameter></paramdef>
41575ebec6dSmrg      </funcprototype>
41675ebec6dSmrg    </funcsynopsis>
417af928962Smrg    <para>
418af928962SmrgThis function sets transport options, similar to the way
419af928962Smrg<function>setsockopt()</function> and <function>ioctl()</function> work.
420af928962SmrgThe parameter <parameter>connection</parameter> is an endpoint
42175ebec6dSmrgthat was obtained from <function>_XTransOpen*()</function> functions.
42275ebec6dSmrgThe parameter <parameter>option</parameter> contains the option that will
42375ebec6dSmrgbe set. The actual values for <parameter>option</parameter> are defined in a
42475ebec6dSmrg<link linkend='Transport_Option_Definition'>later section</link>.
42575ebec6dSmrgThe parameter <parameter>arg</parameter> can be used to pass
42675ebec6dSmrgin an additional value that may be required by some options.
42775ebec6dSmrgThis function returns 0 on success and -1 on failure.
428af928962Smrg    </para>
429af928962Smrg    <note><para>
430af928962SmrgBased on current usage, the complimentary function
431af928962Smrg<function>TRANS(GetOption)</function> is not necessary.
432af928962Smrg    </para></note>
433af928962Smrg  </listitem>
434af928962Smrg  <listitem>
43575ebec6dSmrg    <funcsynopsis id='TRANSCreateListener'>
43675ebec6dSmrg      <funcprototype>
43775ebec6dSmrg        <funcdef>int <function>TRANS(CreateListener)</function></funcdef>
43875ebec6dSmrg        <paramdef>XtransConnInfo <parameter>connection</parameter></paramdef>
4396a3641a6Ssnj        <paramdef>const char *<parameter>port</parameter></paramdef>
44075ebec6dSmrg        <paramdef>int <parameter>flags</parameter></paramdef>
44175ebec6dSmrg      </funcprototype>
44275ebec6dSmrg    </funcsynopsis>
443af928962Smrg    <para>
444af928962SmrgThis function sets up the server endpoint for listening. The parameter
445af928962Smrg<parameter>connection</parameter> is an endpoint that was obtained from
4463d2ed3e3Smrg<function>TRANS(OpenCOTSServer)()</function>. The parameter
44775ebec6dSmrg<parameter>port</parameter> specifies the port to which this endpoint
44875ebec6dSmrgshould be bound for listening. If port is <constant>NULL</constant>,
449af928962Smrgthen the transport may attempt to allocate any available TSAP for this
450af928962Smrgconnection. If the transport cannot support this, then this function will
451af928962Smrgreturn a failure. The <parameter>flags</parameter> parameter can be set
452af928962Smrgto <symbol>ADDR_IN_USE_ALLOWED</symbol> to allow the call to the underlying
453af928962Smrgbinding function to fail with a <errorname>EADDRINUSE</errorname> error
454af928962Smrgwithout causing the <function>TRANS(CreateListener)</function>
455af928962Smrgfunction itself to fail. This function return 0 on success and -1 on failure.
456af928962Smrg    </para>
457af928962Smrg  </listitem>
458af928962Smrg  <listitem>
45975ebec6dSmrg    <funcsynopsis id='TRANSResetListener'>
46075ebec6dSmrg      <funcprototype>
46175ebec6dSmrg        <funcdef>int <function>TRANS(ResetListener)</function></funcdef>
46275ebec6dSmrg        <paramdef>XtransConnInfo <parameter>connection</parameter></paramdef>
46375ebec6dSmrg      </funcprototype>
46475ebec6dSmrg    </funcsynopsis>
465af928962Smrg    <para>
466af928962SmrgWhen a server is restarted, certain listen ports may need to be reset.
467af928962SmrgFor example, unix domain needs to check that the file used for
468af928962Smrgcommunication has not been deleted. If it has, it must be recreated.
469af928962SmrgThe parameter <parameter>connection</parameter> is an opened and bound
470af928962Smrgendpoint that was obtained from <function>TRANS(OpenCOTSServer)()</function>
471af928962Smrgand passed to <function>TRANS(CreateListener)()</function>.
472af928962SmrgThis function will return one of the following values:
473af928962Smrg<symbol>TRANS_RESET_NOOP</symbol>,
474af928962Smrg<symbol>TRANS_RESET_NEW_FD</symbol>, or
475af928962Smrg<symbol>TRANS_RESET_FAILURE</symbol>.
476af928962Smrg    </para>
477af928962Smrg  </listitem>
478af928962Smrg  <listitem>
47975ebec6dSmrg    <funcsynopsis id='TRANSAccept'>
48075ebec6dSmrg      <funcprototype>
48175ebec6dSmrg        <funcdef>XtransConnInfo <function>TRANS(Accept)</function></funcdef>
48275ebec6dSmrg        <paramdef>XtransConnInfo <parameter>connection</parameter></paramdef>
48375ebec6dSmrg      </funcprototype>
48475ebec6dSmrg    </funcsynopsis>
485af928962Smrg    <para>
486af928962SmrgOnce a connection indication is received, this function can be called to
487af928962Smrgaccept the connection. The parameter <parameter>connection</parameter> is
488af928962Smrgan opened and bound endpoint that was obtained from
489af928962Smrg<function>TRANS(OpenCOTSServer)()</function> and passed to
490af928962Smrg<function>TRANS(CreateListener)()</function>. This function will return a
49175ebec6dSmrgnew opaque transport connection object upon success,
49275ebec6dSmrg<constant>NULL</constant> otherwise.
493af928962Smrg    </para>
494af928962Smrg  </listitem>
495af928962Smrg  <listitem>
49675ebec6dSmrg    <funcsynopsis id='TRANSConnect'>
49775ebec6dSmrg      <funcprototype>
49875ebec6dSmrg        <funcdef>int <function>TRANS(Connect)</function></funcdef>
49975ebec6dSmrg        <paramdef>XtransConnInfo <parameter>connection</parameter></paramdef>
5006a3641a6Ssnj        <paramdef>const char *<parameter>address</parameter></paramdef>
50175ebec6dSmrg      </funcprototype>
50275ebec6dSmrg    </funcsynopsis>
503af928962Smrg    <para>
504af928962SmrgThis function creates a connection to a server. The parameter
505af928962Smrg<parameter>connection</parameter> is an endpoint that was obtained
506af928962Smrgfrom <function>TRANS(OpenCOTSClient)()</function>. The parameter
507af928962Smrg<parameter>address</parameter> specifies the TSAP to which this endpoint
50875ebec6dSmrgshould connect. If the protocol is included in the address, it will be
50975ebec6dSmrgignored. This function returns 0 on success and -1 on failure.
510af928962Smrg    </para>
511af928962Smrg  </listitem>
512af928962Smrg  <listitem>
51375ebec6dSmrg    <funcsynopsis id='TRANSBytesReadable'>
51475ebec6dSmrg      <funcprototype>
51575ebec6dSmrg        <funcdef>int <function>TRANS(BytesReadable)</function></funcdef>
51675ebec6dSmrg        <paramdef>XtransConnInfo <parameter>connection</parameter></paramdef>
51775ebec6dSmrg        <paramdef>BytesReadable_t *<parameter>pend</parameter></paramdef>
51875ebec6dSmrg      </funcprototype>
51975ebec6dSmrg    </funcsynopsis>
520af928962Smrg    <para>
52175ebec6dSmrgThis function provides the same functionality as the
52275ebec6dSmrg<function>BytesReadable</function> macro.
523af928962Smrg    </para>
524af928962Smrg  </listitem>
525af928962Smrg  <listitem>
52675ebec6dSmrg    <funcsynopsis id='TRANSRead'>
52775ebec6dSmrg      <funcprototype>
52875ebec6dSmrg        <funcdef>int <function>TRANS(Read)</function></funcdef>
52975ebec6dSmrg        <paramdef>XtransConnInfo <parameter>connection</parameter></paramdef>
53075ebec6dSmrg        <paramdef>char *<parameter>buf</parameter></paramdef>
53175ebec6dSmrg        <paramdef>int <parameter>size</parameter></paramdef>
53275ebec6dSmrg      </funcprototype>
53375ebec6dSmrg    </funcsynopsis>
534af928962Smrg    <para>
535af928962SmrgThis function will return the number of bytes requested on a COTS
5363d2ed3e3Smrgconnection, and will return the minimum of the number bytes requested.
537af928962Smrg    </para>
538af928962Smrg  </listitem>
539af928962Smrg  <listitem>
54075ebec6dSmrg    <funcsynopsis id='TRANSWrite'>
54175ebec6dSmrg      <funcprototype>
54275ebec6dSmrg        <funcdef>int <function>TRANS(Write)</function></funcdef>
54375ebec6dSmrg        <paramdef>XtransConnInfo <parameter>connection</parameter></paramdef>
54475ebec6dSmrg        <paramdef>char *<parameter>buf</parameter></paramdef>
54575ebec6dSmrg        <paramdef>int <parameter>size</parameter></paramdef>
54675ebec6dSmrg      </funcprototype>
54775ebec6dSmrg    </funcsynopsis>
548af928962Smrg    <para>
549af928962SmrgThis function will write the requested number of bytes on a COTS
5503d2ed3e3Smrgconnection.
551af928962Smrg    </para>
552af928962Smrg  </listitem>
553af928962Smrg  <listitem>
55475ebec6dSmrg    <funcsynopsis id='TRANSReadv'>
55575ebec6dSmrg      <funcprototype>
55675ebec6dSmrg        <funcdef>int <function>TRANS(Readv)</function></funcdef>
55775ebec6dSmrg        <paramdef>XtransConnInfo <parameter>connection</parameter></paramdef>
55875ebec6dSmrg        <paramdef>struct iovec *<parameter>buf</parameter></paramdef>
55975ebec6dSmrg        <paramdef>int <parameter>size</parameter></paramdef>
56075ebec6dSmrg      </funcprototype>
56175ebec6dSmrg    </funcsynopsis>
562af928962Smrg    <para>
563af928962SmrgSimilar to <function>TRANS(Read)()</function>.
564af928962Smrg    </para>
565af928962Smrg  </listitem>
566af928962Smrg  <listitem>
56775ebec6dSmrg    <funcsynopsis id='TRANSWritev'>
56875ebec6dSmrg      <funcprototype>
56975ebec6dSmrg        <funcdef>  int <function>TRANS(Writev)</function></funcdef>
57075ebec6dSmrg        <paramdef>XtransConnInfo <parameter>connection</parameter></paramdef>
57175ebec6dSmrg        <paramdef>struct iovec *<parameter>buf</parameter></paramdef>
57275ebec6dSmrg        <paramdef>int <parameter>size</parameter></paramdef>
57375ebec6dSmrg      </funcprototype>
57475ebec6dSmrg    </funcsynopsis>
575af928962Smrg    <para>
576af928962SmrgSimilar to <function>TRANS(Write)()</function>.
577af928962Smrg    </para>
578af928962Smrg  </listitem>
579af928962Smrg  <listitem>
58075ebec6dSmrg    <funcsynopsis id='TRANSDisconnect'>
58175ebec6dSmrg      <funcprototype>
58275ebec6dSmrg        <funcdef>int <function>TRANS(Disconnect)</function></funcdef>
58375ebec6dSmrg        <paramdef>XtransConnInfo <parameter>connection</parameter></paramdef>
58475ebec6dSmrg      </funcprototype>
58575ebec6dSmrg    </funcsynopsis>
586af928962Smrg    <para>
587af928962SmrgThis function is used when an orderly disconnect is desired. This function
588af928962Smrgbreaks the connection on the transport. It is similar to the socket function
589af928962Smrg<function>shutdown()</function>.
590af928962Smrg    </para>
591af928962Smrg  </listitem>
592af928962Smrg  <listitem>
59375ebec6dSmrg    <funcsynopsis id='TRANSClose'>
59475ebec6dSmrg      <funcprototype>
59575ebec6dSmrg        <funcdef>int <function>TRANS(Close)</function></funcdef>
59675ebec6dSmrg        <paramdef>XtransConnInfo <parameter>connection</parameter></paramdef>
59775ebec6dSmrg      </funcprototype>
59875ebec6dSmrg    </funcsynopsis>
599af928962Smrg    <para>
600af928962SmrgThis function closes the transport, unbinds it, and frees all resources that
601af928962Smrgwas associated with the transport. If a <function>TRANS(Disconnect)</function>
602af928962Smrgcall was not made on the connection, a disorderly disconnect may occur.
603af928962Smrg    </para>
604af928962Smrg  </listitem>
605af928962Smrg  <listitem>
60675ebec6dSmrg    <funcsynopsis id='TRANSIsLocal'>
60775ebec6dSmrg      <funcprototype>
60875ebec6dSmrg        <funcdef>int <function>TRANS(IsLocal)</function></funcdef>
60975ebec6dSmrg        <paramdef>XtransConnInfo <parameter>connection</parameter></paramdef>
61075ebec6dSmrg      </funcprototype>
61175ebec6dSmrg    </funcsynopsis>
612af928962Smrg    <para>
613af928962SmrgReturns TRUE if it is a local transport.
614af928962Smrg    </para>
615af928962Smrg  </listitem>
616af928962Smrg  <listitem>
61775ebec6dSmrg    <funcsynopsis id='TRANSGetMyAddr'>
61875ebec6dSmrg      <funcprototype>
61975ebec6dSmrg        <funcdef>int <function>TRANS(GetMyAddr)</function></funcdef>
62075ebec6dSmrg        <paramdef>XtransConnInfo <parameter>connection</parameter></paramdef>
62175ebec6dSmrg        <paramdef>int *<parameter>familyp</parameter></paramdef>
62275ebec6dSmrg        <paramdef>int *<parameter>addrlenp</parameter></paramdef>
62375ebec6dSmrg        <paramdef>Xtransaddr **<parameter>addrp</parameter></paramdef>
62475ebec6dSmrg       </funcprototype>
62575ebec6dSmrg    </funcsynopsis>
62675ebec6dSmrg    <para>
62775ebec6dSmrgThis function is similar to <function>getsockname()</function>.
628af928962SmrgThis function will allocate space for the address, so it must be freed by
629af928962Smrgthe caller. Not all transports will have a valid address until a connection
630af928962Smrgis established.  This function should not be used until the connection is
63175ebec6dSmrgestablished with <function>Connect()</function> or
632af928962Smrg<function>Accept()</function>.
633af928962Smrg    </para>
634af928962Smrg  </listitem>
635af928962Smrg  <listitem>
63675ebec6dSmrg    <funcsynopsis id='TRANSGetPeerAddr'>
63775ebec6dSmrg      <funcprototype>
63875ebec6dSmrg        <funcdef>int <function>TRANS(GetPeerAddr)</function></funcdef>
63975ebec6dSmrg        <paramdef>XtransConnInfo <parameter>connection</parameter></paramdef>
64075ebec6dSmrg        <paramdef>int *<parameter>familyp</parameter></paramdef>
64175ebec6dSmrg        <paramdef>int *<parameter>addrlenp</parameter></paramdef>
64275ebec6dSmrg        <paramdef>Xtransaddr **<parameter>addrp</parameter></paramdef>
64375ebec6dSmrg       </funcprototype>
64475ebec6dSmrg    </funcsynopsis>
64575ebec6dSmrg    <para>
64675ebec6dSmrgThis function is similar to <function>getpeername()</function>.
647af928962SmrgThis function will allocate space for the address, so it must be freed by
648af928962Smrgthe caller. Not all transports will have a valid address until a connection
649af928962Smrgis established.  This function should not be used until the connection is
65075ebec6dSmrgestablished with <function>Connect()</function> or
651af928962Smrg<function>Accept()</function>.
652af928962Smrg    </para>
653af928962Smrg  </listitem>
654af928962Smrg  <listitem>
65575ebec6dSmrg    <funcsynopsis id='TRANSGetConnectionNumber'>
65675ebec6dSmrg      <funcprototype>
65775ebec6dSmrg        <funcdef>int <function>TRANS(GetConnectionNumber)</function></funcdef>
65875ebec6dSmrg        <paramdef>XtransConnInfo <parameter>connection</parameter></paramdef>
65975ebec6dSmrg      </funcprototype>
66075ebec6dSmrg    </funcsynopsis>
661af928962Smrg    <para>
662af928962SmrgReturns the file descriptor associated with this transport.
663af928962Smrg    </para>
664af928962Smrg  </listitem>
665af928962Smrg  <listitem>
66675ebec6dSmrg    <funcsynopsis id='TRANSMakeAllCOTSServerListeners'>
66775ebec6dSmrg      <funcprototype>
66875ebec6dSmrg        <funcdef>int <function>TRANS(MakeAllCOTSServerListeners)</function></funcdef>
6696a3641a6Ssnj        <paramdef>const char *<parameter>port</parameter></paramdef>
67075ebec6dSmrg        <paramdef>int *<parameter>partial_ret</parameter></paramdef>
67175ebec6dSmrg        <paramdef>int *<parameter>count_ret</parameter></paramdef>
67275ebec6dSmrg        <paramdef>XtransConnInfo **<parameter>connections_ret</parameter></paramdef>
67375ebec6dSmrg      </funcprototype>
67475ebec6dSmrg    </funcsynopsis>
675af928962Smrg    <para>
676af928962SmrgThis function should be used by most servers. It will try to establish
677af928962Smrga COTS server endpoint for each transport listed in the transport table.
678af928962Smrg<parameter>partial_ret</parameter> will be set to <symbol>True</symbol> if
679af928962Smrgonly a partial network could be created. <parameter>count_ret</parameter> is
680af928962Smrgthe number of transports returned, and <parameter>connections_ret</parameter>
681af928962Smrgis the list of transports.
682af928962Smrg    </para>
683af928962Smrg  </listitem>
684af928962Smrg</itemizedlist>
685af928962Smrg</sect1>
686af928962Smrg
687fe567363Smrg<sect1 id='Utility_API'>
688af928962Smrg<title>Utility API</title>
689af928962Smrg<para>
690af928962SmrgThis section describes a few useful functions that have been implemented on
691af928962Smrgtop of the Core Interface API.  These functions are being provided as a
692af928962Smrgconvenience.
693af928962Smrg</para>
694af928962Smrg<itemizedlist mark='bullet'>
695af928962Smrg  <listitem>
69675ebec6dSmrg    <funcsynopsis id='TRANSConvertAddress'>
69775ebec6dSmrg      <funcprototype>
69875ebec6dSmrg        <funcdef>int <function>TRANS(ConvertAddress)</function></funcdef>
69975ebec6dSmrg        <paramdef>int *<parameter>familyp</parameter></paramdef>
70075ebec6dSmrg        <paramdef>int *<parameter>addrlenp</parameter></paramdef>
70175ebec6dSmrg        <paramdef>Xtransaddr *<parameter>addrp</parameter></paramdef>
70275ebec6dSmrg      </funcprototype>
70375ebec6dSmrg    </funcsynopsis>
704af928962Smrg    <para>
705af928962SmrgThis function converts a sockaddr based address to an X authorization based
70675ebec6dSmrgaddress (ie <symbol>AF_INET</symbol>, <symbol>AF_UNIX</symbol> to the X
70775ebec6dSmrgprotocol definition (ie <symbol>FamilyInternet</symbol>,
70875ebec6dSmrg<symbol>FamilyLocal</symbol>)).
709af928962Smrg    </para>
710af928962Smrg  </listitem>
711af928962Smrg</itemizedlist>
712af928962Smrg</sect1>
713af928962Smrg</chapter>
714af928962Smrg
715fe567363Smrg<chapter id='Transport_Option_Definition'>
716af928962Smrg<title>Transport Option Definition</title>
717af928962Smrg<para>
718af928962SmrgThe following options are defined for the
71975ebec6dSmrg<link linkend='TRANSSetOption'><function>TRANS(SetOption)()</function></link>
72075ebec6dSmrgfunction. If an OS or transport does not support any of these options,
721af928962Smrgthen it will silently ignore the option.
722af928962Smrg</para>
723af928962Smrg
724af928962Smrg<itemizedlist mark='bullet'>
725af928962Smrg  <listitem>
726af928962Smrg    <para>
727af928962Smrg<symbol>TRANS_NONBLOCKING</symbol>
728af928962Smrg    </para>
729af928962Smrg    <para>
730af928962SmrgThis option controls the blocking mode of the connection. If the argument
731af928962Smrgis set to 1, then the connection will be set to blocking. If the argument
732af928962Smrgis set to 0, then the connection will be set to non- blocking.
733af928962Smrg    </para>
734af928962Smrg  </listitem>
735af928962Smrg  <listitem>
736af928962Smrg    <para>
737af928962Smrg<symbol>TRANS_CLOSEONEXEC</symbol>
738af928962Smrg    </para>
739af928962Smrg    <para>
740af928962SmrgThis option determines what will happen to the connection when an exec is
741af928962Smrgencountered. If the argument is set to 1, then the connection will be
742af928962Smrgclosed when an exec occurs. If the argument is set to 0, then the
743af928962Smrgconnection will not be closed when an exec occurs.
744af928962Smrg    </para>
745af928962Smrg  </listitem>
746af928962Smrg</itemizedlist>
747af928962Smrg</chapter>
748af928962Smrg
749fe567363Smrg<chapter id='Hidden_Transport_Dependent_API'>
750af928962Smrg<title>Hidden Transport Dependent API</title>
751af928962Smrg<para>
752af928962SmrgThe hidden transport dependent functions are placed in the Xtransport record.
753af928962SmrgThese function are similar to the Exposed Transport Independent API, but
754af928962Smrgsome of the parameters and return values are slightly different.  Stuff like
755af928962Smrgthe <code>#ifdef SUNSYSV</code> should be handled inside these functions.
756af928962Smrg</para>
757af928962Smrg
758af928962Smrg<itemizedlist mark='bullet'>
759af928962Smrg  <listitem>
76075ebec6dSmrg    <funcsynopsis id='OpenCOTSClient'>
76175ebec6dSmrg      <funcprototype>
76275ebec6dSmrg        <funcdef>XtransConnInfo *<function>OpenCOTSClient</function></funcdef>
76375ebec6dSmrg        <paramdef>struct _Xtransport *<parameter>thistrans</parameter></paramdef>
7646a3641a6Ssnj        <paramdef>const char *<parameter>protocol</parameter></paramdef>
7656a3641a6Ssnj        <paramdef>const char *<parameter>host</parameter></paramdef>
7666a3641a6Ssnj        <paramdef>const char *<parameter>port</parameter></paramdef>
76775ebec6dSmrg      </funcprototype>
76875ebec6dSmrg    </funcsynopsis>
769af928962Smrg    <para>
770af928962SmrgThis function creates a Connection-Oriented Transport. The parameter
77175ebec6dSmrg<parameter>thistrans</parameter> points to an Xtransport entry in the
77275ebec6dSmrgtransport table. The parameters <parameter>protocol</parameter>,
77375ebec6dSmrg<parameter>host</parameter>, and <parameter>port</parameter>, point to
77475ebec6dSmrgstrings containing the corresponding parts of the address that was passed into
77575ebec6dSmrg<link linkend='TRANSOpenCOTSClient'><function>TRANS(OpenCOTSClient)()</function></link>.
776af928962SmrgThis function must allocate and initialize the contents of the XtransConnInfo
777af928962Smrgstructure that is returned by this function. This function will open the
778af928962Smrgtransport, and bind it into the transport namespace if applicable. The local
779af928962Smrgaddress portion of the XtransConnInfo structure will also be filled in by
780af928962Smrgthis function.
781af928962Smrg    </para>
782af928962Smrg  </listitem>
783af928962Smrg  <listitem>
78475ebec6dSmrg    <funcsynopsis id='OpenCOTSServer'>
78575ebec6dSmrg      <funcprototype>
78675ebec6dSmrg        <funcdef>XtransConnInfo *<function>OpenCOTSServer</function></funcdef>
78775ebec6dSmrg        <paramdef>struct _Xtransport *<parameter>thistrans</parameter></paramdef>
7886a3641a6Ssnj        <paramdef>const char *<parameter>protocol</parameter></paramdef>
7896a3641a6Ssnj        <paramdef>const char *<parameter>host</parameter></paramdef>
7906a3641a6Ssnj        <paramdef>const char *<parameter>port</parameter></paramdef>
79175ebec6dSmrg      </funcprototype>
79275ebec6dSmrg    </funcsynopsis>
793af928962Smrg    <para>
794af928962SmrgThis function creates a Connection-Oriented Transport. The parameter
79575ebec6dSmrg<parameter>thistrans</parameter> points to an Xtransport entry in the
79675ebec6dSmrgtransport table. The parameters <parameter>protocol</parameter>,
79775ebec6dSmrg<parameter>host</parameter>, and <parameter>port</parameter> point to
79875ebec6dSmrgstrings containing the corresponding parts of the address that was passed into
79975ebec6dSmrg<link linkend='TRANSOpenCOTSServer'><function>TRANS(OpenCOTSServer)()</function></link>.
800af928962SmrgThis function must allocate and initialize the contents of the
801af928962SmrgXtransConnInfo structure that is returned by this function. This function
802af928962Smrgwill open the transport.
803af928962Smrg    </para>
804af928962Smrg  </listitem>
805af928962Smrg  <listitem>
80675ebec6dSmrg    <funcsynopsis id='SetOption'>
80775ebec6dSmrg      <funcprototype>
80875ebec6dSmrg        <funcdef>int <function>SetOption</function></funcdef>
80975ebec6dSmrg        <paramdef>struct _Xtransport *<parameter>thistrans</parameter></paramdef>
81075ebec6dSmrg        <paramdef>int <parameter>option</parameter></paramdef>
81175ebec6dSmrg        <paramdef>int <parameter>arg</parameter></paramdef>
81275ebec6dSmrg      </funcprototype>
81375ebec6dSmrg    </funcsynopsis>
814af928962Smrg    <para>
815af928962SmrgThis function provides a transport dependent way of implementing the
816af928962Smrgoptions defined by the X Transport Interface. In the current prototype,
817af928962Smrgthis function is not being used, because all of the options defined so far
818af928962Smrgare transport independent. This function will have to be used if a radically
819af928962Smrgdifferent transport type is added, or a transport dependent option is defined.
820af928962Smrg    </para>
821af928962Smrg  </listitem>
822af928962Smrg  <listitem>
82375ebec6dSmrg    <funcsynopsis id='CreateListener'>
82475ebec6dSmrg      <funcprototype>
82575ebec6dSmrg        <funcdef>int <function>CreateListener</function></funcdef>
82675ebec6dSmrg        <paramdef>struct _Xtransport *<parameter>thistrans</parameter></paramdef>
8276a3641a6Ssnj        <paramdef>const char <parameter>*port</parameter></paramdef>
82875ebec6dSmrg        <paramdef>int <parameter>flags</parameter></paramdef>
82975ebec6dSmrg      </funcprototype>
83075ebec6dSmrg    </funcsynopsis>
831af928962Smrg    <para>
832af928962SmrgThis function takes a transport endpoint opened for a server, and sets it
833af928962Smrgup to listen for incoming connection requests. The parameter
834af928962Smrg<parameter>port</parameter>
835af928962Smrgcontains the port portion of the address that was passed to the Open function.
836af928962SmrgThe parameter <parameter>flags</parameter> should be set to
837af928962Smrg<symbol>ADDR_IN_USE_ALLOWED</symbol> if the underlying transport endpoint
838af928962Smrgmay be already bound and this should not be considered
839af928962Smrgas an error. Otherwise flags should be set to 0. This is used by IPv6 code,
840af928962Smrgwhere the same socket can be bound to both an IPv6 address and then to a
841af928962SmrgIPv4 address.  This function will bind the transport into the transport
842af928962Smrgname space if applicable, and fill in the local address portion of the
843af928962SmrgXtransConnInfo structure. The transport endpoint will then be set to
844af928962Smrglisten for incoming connection requests.
845af928962Smrg    </para>
846af928962Smrg  </listitem>
847af928962Smrg  <listitem>
84875ebec6dSmrg    <funcsynopsis id='ResetListener'>
84975ebec6dSmrg      <funcprototype>
85075ebec6dSmrg        <funcdef>int <function>ResetListener</function></funcdef>
85175ebec6dSmrg        <paramdef>struct _Xtransport *<parameter>thistrans</parameter></paramdef>
85275ebec6dSmrg      </funcprototype>
85375ebec6dSmrg    </funcsynopsis>
854af928962Smrg    <para>
855af928962SmrgThis function resets the transport for listening.
856af928962Smrg    </para>
857af928962Smrg  </listitem>
858af928962Smrg  <listitem>
85975ebec6dSmrg    <funcsynopsis id='Accept'>
86075ebec6dSmrg      <funcprototype>
86175ebec6dSmrg        <funcdef> XtransConnInfo <function>Accept</function></funcdef>
86275ebec6dSmrg        <paramdef>struct _Xtransport *<parameter>thistrans</parameter></paramdef>
86375ebec6dSmrg      </funcprototype>
86475ebec6dSmrg    </funcsynopsis>
865af928962Smrg    <para>
866af928962SmrgThis function creates a new transport endpoint as a result of an
867af928962Smrgincoming connection request. The parameter
868af928962Smrg<parameter>thistrans</parameter> is the endpoint
869af928962Smrgthat was opened for listening by the server. The new endpoint is
870af928962Smrgopened and bound into the transport’s namespace. A XtransConnInfo
871af928962Smrgstructure describing the new endpoint is returned from this function
872af928962Smrg    </para>
873af928962Smrg  </listitem>
874af928962Smrg  <listitem>
87575ebec6dSmrg    <funcsynopsis id='Connect'>
87675ebec6dSmrg      <funcprototype>
87775ebec6dSmrg        <funcdef>int <function>Connect</function></funcdef>
87875ebec6dSmrg        <paramdef>struct _Xtransport *<parameter>thistrans</parameter></paramdef>
8796a3641a6Ssnj        <paramdef>const char *<parameter>host</parameter></paramdef>
8806a3641a6Ssnj        <paramdef>const char *<parameter>port</parameter></paramdef>
88175ebec6dSmrg      </funcprototype>
88275ebec6dSmrg    </funcsynopsis>
883af928962Smrg    <para>
884af928962SmrgThis function establishes a connection to a server. The parameters
88575ebec6dSmrg<parameter>host</parameter> and <parameter>port</parameter>
886af928962Smrgdescribe the server to which the connection should be
887af928962Smrgestablished. The connection will be established so that
888af928962Smrg<function>Read()</function> and
889af928962Smrg<function>Write()</function> call can be made.
890af928962Smrg    </para>
891af928962Smrg  </listitem>
892af928962Smrg  <listitem>
89375ebec6dSmrg    <funcsynopsis id='BytesReadable'>
89475ebec6dSmrg      <funcprototype>
89575ebec6dSmrg        <funcdef>int <function>BytesReadable</function></funcdef>
89675ebec6dSmrg        <paramdef>struct _Xtransport *<parameter>thistrans</parameter></paramdef>
89775ebec6dSmrg        <paramdef>BytesReadable_t *<parameter>pend</parameter></paramdef>
89875ebec6dSmrg      </funcprototype>
89975ebec6dSmrg    </funcsynopsis>
90075ebec6dSmrg    <para>
90175ebec6dSmrgThis function replaces the <function>BytesReadable()</function>
90275ebec6dSmrgmacro. This allows each transport to have its own mechanism for determining
903af928962Smrghow much data is ready to be read.
904af928962Smrg    </para>
905af928962Smrg  </listitem>
906af928962Smrg  <listitem>
90775ebec6dSmrg    <funcsynopsis id='Read'>
90875ebec6dSmrg      <funcprototype>
90975ebec6dSmrg        <funcdef>int <function>Read</function></funcdef>
91075ebec6dSmrg        <paramdef>struct _Xtransport *<parameter>thistrans</parameter></paramdef>
91175ebec6dSmrg        <paramdef>char *<parameter>buf</parameter></paramdef>
91275ebec6dSmrg        <paramdef>int <parameter>size</parameter></paramdef>
91375ebec6dSmrg      </funcprototype>
91475ebec6dSmrg    </funcsynopsis>
91575ebec6dSmrg    <para>
91675ebec6dSmrgThis function reads <parameter>size</parameter> bytes into
91775ebec6dSmrg<parameter>buf</parameter> from the connection.
918af928962Smrg    </para>
919af928962Smrg  </listitem>
920af928962Smrg  <listitem>
92175ebec6dSmrg    <funcsynopsis id='Write'>
92275ebec6dSmrg      <funcprototype>
92375ebec6dSmrg        <funcdef>int <function>Write</function></funcdef>
92475ebec6dSmrg        <paramdef>struct _Xtransport *<parameter>thistrans</parameter></paramdef>
92575ebec6dSmrg        <paramdef>char *<parameter>buf</parameter></paramdef>
92675ebec6dSmrg        <paramdef>int <parameter>size</parameter></paramdef>
92775ebec6dSmrg      </funcprototype>
92875ebec6dSmrg    </funcsynopsis>
92975ebec6dSmrg    <para>
93075ebec6dSmrgThis function writes <parameter>size</parameter> bytes from
93175ebec6dSmrg<parameter>buf</parameter> to the connection.
932af928962Smrg    </para>
933af928962Smrg  </listitem>
934af928962Smrg  <listitem>
93575ebec6dSmrg    <funcsynopsis id='Readv'>
93675ebec6dSmrg      <funcprototype>
93775ebec6dSmrg        <funcdef>int <function>Readv</function></funcdef>
93875ebec6dSmrg        <paramdef>struct _Xtransport *<parameter>thistrans</parameter></paramdef>
93975ebec6dSmrg        <paramdef>struct iovec *<parameter>buf</parameter></paramdef>
94075ebec6dSmrg        <paramdef>int <parameter>size</parameter></paramdef>
94175ebec6dSmrg      </funcprototype>
94275ebec6dSmrg    </funcsynopsis>
943af928962Smrg    <para>
944af928962SmrgThis function performs a <function>readv()</function> on the connection.
945af928962Smrg    </para>
946af928962Smrg  </listitem>
947af928962Smrg  <listitem>
94875ebec6dSmrg    <funcsynopsis id='Writev'>
94975ebec6dSmrg      <funcprototype>
95075ebec6dSmrg        <funcdef>int <function>Writev</function></funcdef>
95175ebec6dSmrg        <paramdef>struct _Xtransport *<parameter>thistrans</parameter></paramdef>
95275ebec6dSmrg        <paramdef>struct iovec *<parameter>buf</parameter></paramdef>
95375ebec6dSmrg        <paramdef>int <parameter>size</parameter></paramdef>
95475ebec6dSmrg      </funcprototype>
95575ebec6dSmrg    </funcsynopsis>
956af928962Smrg    <para>
957af928962SmrgThis function performs a <function>writev()</function> on the connection.
958af928962Smrg    </para>
959af928962Smrg  </listitem>
960af928962Smrg  <listitem>
96175ebec6dSmrg    <funcsynopsis id='Disconnect'>
96275ebec6dSmrg      <funcprototype>
96375ebec6dSmrg        <funcdef>int <function>Disconnect</function></funcdef>
96475ebec6dSmrg        <paramdef>struct _Xtransport *<parameter>thistrans</parameter></paramdef>
96575ebec6dSmrg      </funcprototype>
96675ebec6dSmrg    </funcsynopsis>
967af928962Smrg    <para>
968af928962SmrgThis function initiates an orderly shutdown of a connection. If a
969af928962Smrgtransport does not distinguish between orderly and disorderly
970af928962Smrgdisconnects, then a call to this function will have no affect.
971af928962Smrg    </para>
972af928962Smrg  </listitem>
973af928962Smrg  <listitem>
97475ebec6dSmrg    <funcsynopsis id='Close'>
97575ebec6dSmrg      <funcprototype>
97675ebec6dSmrg        <funcdef>int <function>Close</function></funcdef>
97775ebec6dSmrg        <paramdef>struct _Xtransport *<parameter>thistrans</parameter></paramdef>
97875ebec6dSmrg      </funcprototype>
97975ebec6dSmrg    </funcsynopsis>
980af928962Smrg    <para>
981af928962SmrgThis function will break the connection, and close the endpoint.
982af928962Smrg    </para>
983af928962Smrg  </listitem>
984af928962Smrg</itemizedlist>
985af928962Smrg</chapter>
986fe567363Smrg<chapter id='Configuration'>
987af928962Smrg<title>Configuration</title>
988af928962Smrg
989af928962Smrg<para>
990af928962SmrgThe implementation of each transport can be platform specific. It is expected
991af928962Smrgthat existing connection types such as <symbol>TCPCONN</symbol>,
992af928962Smrg<symbol>UNIXCONN</symbol>, <symbol>LOCALCONN</symbol>, and
993af928962Smrg<symbol>STREAMSCONN</symbol> will be replaced with flags for each
994af928962Smrgpossible transport type.
995af928962Smrg</para>
996af928962Smrg<para>
997af928962SmrgIn X11R6, the below flags to enable transport types were set in
998af928962Smrg<symbol>ConnectionFlags</symbol> in the <filename>vendor.cf</filename> or
999af928962Smrg<filename>site.def</filename> config files.
1000af928962Smrg</para>
1001af928962Smrg<para>
1002af928962SmrgIn X11R7 modular releases, these flags are set when running
1003af928962Smrg<filename>configure</filename> scripts which include the
1004af928962Smrg<function>XTRANS_CONNECTION_FLAGS</function> macro from
1005af928962Smrg<filename>xtrans.m4</filename>.
1006af928962Smrg</para>
1007fe567363Smrg
1008fe567363Smrg<informaltable frame='topbot'>
1009fe567363Smrg  <tgroup cols='3' align='left' colsep='0' rowsep='0'>
1010fe567363Smrg    <colspec colname='define' colwidth='1.0*' />
1011fe567363Smrg    <colspec colname='enable' colwidth='2.0*' />
1012fe567363Smrg    <colspec colname='desc'   colwidth='2.0*'/>
1013af928962Smrg    <thead>
1014fe567363Smrg      <row rowsep='1'>
1015af928962Smrg	<entry><code>#define</code></entry>
1016af928962Smrg	<entry>configure flag</entry>
1017af928962Smrg	<entry>Description</entry>
1018af928962Smrg      </row>
1019af928962Smrg    </thead>
1020af928962Smrg    <tbody>
1021af928962Smrg      <row>
1022af928962Smrg	<entry><symbol>TCPCONN</symbol></entry>
1023af928962Smrg	<entry><option>--enable-tcp-transport</option></entry>
1024af928962Smrg	<entry>
1025af928962Smrg	Enables the INET (IPv4) Domain Socket based transport
1026af928962Smrg	</entry>
1027af928962Smrg      </row>
1028af928962Smrg      <row>
1029af928962Smrg	<entry><symbol>IPv6</symbol></entry>
1030af928962Smrg	<entry><option>--enable-ipv6</option></entry>
1031af928962Smrg	<entry>
1032af928962Smrg	Extends <symbol>TCPCONN</symbol> to enable IPv6 Socket based transport
1033af928962Smrg	</entry>
1034af928962Smrg      </row>
1035af928962Smrg      <row>
1036af928962Smrg	<entry><symbol>UNIXCONN</symbol></entry>
1037af928962Smrg	<entry><option>--enable-unix-transport</option></entry>
1038af928962Smrg	<entry>
1039af928962Smrg	Enables the UNIX Domain Socket based transport
1040af928962Smrg	</entry>
1041af928962Smrg      </row>
1042af928962Smrg      <row>
1043af928962Smrg	<entry><symbol>STREAMSCONN</symbol></entry>
1044af928962Smrg	<entry><emphasis>Not available in X11R7</emphasis></entry>
1045af928962Smrg	<entry>
1046af928962Smrg	Enables the TLI based transports
1047af928962Smrg	</entry>
1048af928962Smrg      </row>
1049af928962Smrg      <row>
1050af928962Smrg	<entry><symbol>LOCALCONN</symbol></entry>
1051af928962Smrg	<entry><option>--enable-local-transport</option></entry>
1052af928962Smrg	<entry>
1053af928962Smrg	Enables the SYSV Local connection transports
1054af928962Smrg	</entry>
1055af928962Smrg      </row>
1056af928962Smrg      <row>
1057af928962Smrg	<entry><symbol>DNETCONN</symbol></entry>
1058af928962Smrg	<entry><emphasis>Not available in X11R7</emphasis></entry>
1059af928962Smrg	<entry>
1060af928962Smrg	Enables the DECnet transports
1061af928962Smrg	</entry>
1062af928962Smrg      </row>
1063af928962Smrg    </tbody>
1064af928962Smrg  </tgroup>
1065af928962Smrg</informaltable>
1066af928962Smrg
1067af928962Smrg
1068af928962Smrg</chapter>
1069af928962Smrg
1070fe567363Smrg<chapter id='Transport_Specific_Definitions'>
1071af928962Smrg<title>Transport Specific Definitions</title>
1072af928962Smrg
1073fe567363Smrg<informaltable frame='all' colsep='1' rowsep='1'>
1074af928962Smrg  <tgroup cols='4' align='center'>
1075fe567363Smrg    <colspec colname='c1' colwidth='1.0*'/>
1076fe567363Smrg    <colspec colname='c2' colwidth='1.0*'/>
1077fe567363Smrg    <colspec colname='c3' colwidth='3.0*'/>
1078fe567363Smrg    <colspec colname='c4' colwidth='2.0*'/>
1079af928962Smrg    <thead>
1080af928962Smrg      <row>
1081fe567363Smrg        <entry morerows="1">Protocol Family</entry>
1082af928962Smrg        <entry namest="c2" nameend="c4"  align='center'>Address Component</entry>
1083af928962Smrg      </row>
1084af928962Smrg      <row>
1085af928962Smrg        <entry align='center'>protocol</entry>
1086af928962Smrg        <entry align='center'>host</entry>
1087af928962Smrg        <entry align='center'>port</entry>
1088af928962Smrg      </row>
1089af928962Smrg    </thead>
1090af928962Smrg    <tbody>
1091af928962Smrg      <row>
1092fe567363Smrg        <entry>Internet</entry>
1093fe567363Smrg        <entry>inet inet6 tcp udp</entry>
1094fe567363Smrg        <entry>name of an internet addressable host</entry>
1095fe567363Smrg        <entry>string containing the name of a service or a valid port number.  Example: "xserver0", "7100"</entry>
1096af928962Smrg      </row>
1097af928962Smrg      <row>
1098fe567363Smrg        <entry>DECnet</entry>
1099fe567363Smrg        <entry>decnet</entry>
1100fe567363Smrg        <entry>name of a DECnet addressable host</entry>
1101fe567363Smrg        <entry>string containing the complete name of the object.  Example: "X$X0"</entry>
1102af928962Smrg      </row>
1103af928962Smrg      <row>
1104fe567363Smrg        <entry>NETware</entry>
1105fe567363Smrg        <entry>ipx</entry>
1106fe567363Smrg        <entry>name of a NETware addressable host</entry>
1107fe567363Smrg        <entry>Not sure of the specifics yet.</entry>
1108af928962Smrg      </row>
1109af928962Smrg      <row>
1110fe567363Smrg        <entry>OSI</entry>
1111fe567363Smrg        <entry>osi</entry>
1112e45ace2bSmrg        <entry>name of an OSI addressable host.</entry>
1113fe567363Smrg        <entry>Not sure of the specifics yet.</entry>
1114af928962Smrg      </row>
1115af928962Smrg      <row>
1116fe567363Smrg        <entry>Local</entry>
1117fe567363Smrg        <entry>local pts named sco isc</entry>
1118fe567363Smrg        <entry>(ignored)</entry>
1119fe567363Smrg        <entry>String containing the port name, ie "xserver0", "fontserver0".</entry>
1120af928962Smrg      </row>
1121af928962Smrg    </tbody>
1122af928962Smrg  </tgroup>
1123af928962Smrg</informaltable>
1124af928962Smrg
1125af928962Smrg</chapter>
1126af928962Smrg
1127fe567363Smrg<chapter id='Implementation_Notes'>
1128af928962Smrg<title>Implementation Notes</title>
1129af928962Smrg<para>
1130af928962SmrgThis section refers to the prototype implementation that is being developed
1131af928962Smrgconcurrently with this document. This prototype has been able to flush out many
1132af928962Smrgdetails and problems as the specification was being developed.
1133af928962Smrg</para>
1134af928962Smrg<para>
1135af928962SmrgIn X11R6, all of the source code for this interface was located in
1136af928962Smrg<filename>xc/lib/xtrans</filename>.
1137af928962Smrg</para>
1138af928962Smrg<para>
1139af928962SmrgIn X11R7, all of the source code for this interface is delivered via
1140af928962Smrgthe <systemitem>lib/libxtrans</systemitem> modular package from X.Org,
1141af928962Smrgand is installed under
1142af928962Smrg<filename><replaceable>${prefix}</replaceable>/X11/Xtrans</filename>
1143af928962Smrgso that other modules may find it when they build.
1144af928962Smrg</para>
1145af928962Smrg<para>
1146af928962SmrgAll functions names in the source are of the format
1147af928962Smrg<function>TRANS(func)()</function>. The
1148af928962Smrg<function>TRANS()</function>
1149af928962Smrgmacro is defined as
1150af928962Smrg<programlisting language="C">
1151af928962Smrg#define TRANS(func) _PROTOCOLTrans##func
1152af928962Smrg</programlisting>
1153af928962Smrg</para>
1154af928962Smrg
1155af928962Smrg<para>
1156af928962Smrg<symbol>PROTOCOL</symbol> will be uniquely defined in each directory
1157af928962Smrgwhere this code is compiled.
1158af928962Smrg<symbol>PROTOCOL</symbol> will be defined to be the name of the protocol
1159af928962Smrgthat is implemented by the library or server, such as X11, FS, and ICE.
1160af928962Smrg</para>
1161af928962Smrg
1162af928962Smrg<para>
1163af928962SmrgAll libraries and servers that use the X Transport Interface should have a new
1164af928962Smrgfile called <filename><replaceable>TRANSPORT</replaceable>trans.c</filename>.
1165af928962SmrgThis file will include the transports based on the configuration flags
1166af928962Smrgprovided by the <filename>configure</filename> script. Below is an
1167af928962Smrgexample <filename>xfstrans.c</filename> for the font server.
1168af928962Smrg</para>
1169af928962Smrg
1170af928962Smrg<programlisting language="C">
1171af928962Smrg#include "config.h"
1172af928962Smrg
1173af928962Smrg#define FONT_t 1
1174af928962Smrg#define TRANS_REOPEN 1
1175af928962Smrg#define TRANS_SERVER 1
1176af928962Smrg
1177af928962Smrg#include &lt;X11/Xtrans/transport.c&gt;
1178af928962Smrg</programlisting>
1179af928962Smrg<para>
1180af928962SmrgThe source files for this interface are listed below.
1181af928962Smrg</para>
1182af928962Smrg
1183af928962Smrg<variablelist>
1184af928962Smrg  <varlistentry>
1185af928962Smrg    <term><filename>Xtrans.h</filename></term>
1186af928962Smrg    <listitem><para>
1187af928962SmrgFunction prototypes and defines for the Transport Independent API.
1188af928962Smrg    </para></listitem>
1189af928962Smrg  </varlistentry>
1190af928962Smrg  <varlistentry>
1191af928962Smrg    <term><filename>Xtransint.h</filename></term>
1192af928962Smrg    <listitem><para>
1193af928962SmrgUsed by the interface implementation only.
1194af928962SmrgContains the internal data structures.
1195af928962Smrg    </para></listitem>
1196af928962Smrg  </varlistentry>
1197af928962Smrg  <varlistentry>
1198af928962Smrg    <term><filename>Xtranssock.c</filename></term>
1199af928962Smrg    <listitem><para>
1200af928962SmrgSocket implementation of the Transport Dependent API.
1201af928962Smrg    </para></listitem>
1202af928962Smrg  </varlistentry>
1203af928962Smrg  <varlistentry>
1204af928962Smrg    <term><filename>Xtranstli.c</filename></term>
1205af928962Smrg    <listitem><para>
1206af928962SmrgTLI implementation of the Transport Dependent API.
1207af928962Smrg    </para></listitem>
1208af928962Smrg  </varlistentry>
1209af928962Smrg  <varlistentry>
1210af928962Smrg    <term><filename>Xtransdnet.c</filename></term>
1211af928962Smrg    <listitem><para>
1212af928962SmrgDECnet implementation of the Transport Dependent API.
1213af928962Smrg    </para></listitem>
1214af928962Smrg  </varlistentry>
1215af928962Smrg  <varlistentry>
1216af928962Smrg    <term><filename>Xtranslocal.c</filename></term>
1217af928962Smrg    <listitem><para>
1218af928962SmrgImplementation of the Transport Dependent API for SYSV Local connections.
1219af928962Smrg    </para></listitem>
1220af928962Smrg  </varlistentry>
1221af928962Smrg  <varlistentry>
1222af928962Smrg    <term><filename>Xtrans.c</filename></term>
1223af928962Smrg    <listitem><para>
1224af928962SmrgExposed Transport Independent API Functions.
1225af928962Smrg    </para></listitem>
1226af928962Smrg  </varlistentry>
1227af928962Smrg  <varlistentry>
1228af928962Smrg    <term><filename>Xtransutil.c</filename></term>
1229af928962Smrg    <listitem><para>
1230af928962SmrgCollection of Utility functions that use the X Transport Interface.
1231af928962Smrg    </para></listitem>
1232af928962Smrg  </varlistentry>
1233af928962Smrg</variablelist>
1234af928962Smrg
1235af928962Smrg
1236af928962Smrg<para>
1237af928962SmrgThe file <filename>Xtransint.h</filename> contains much of the transport
1238af928962Smrgrelated code that was previously in <filename>Xlibint.h</filename> and
1239af928962Smrg<filename>Xlibnet.h</filename>.
1240af928962SmrgThis will make the definitions available for all transport users. This
1241af928962Smrgshould also obsolete the equivalent code in other libraries.
1242af928962Smrg</para>
1243af928962Smrg
1244af928962Smrg</chapter>
1245af928962Smrg</book>
1246