<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>Apache Portable Runtime: apr_network_io.h Source File</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.3.9.1 --> <div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a></div> <div class="nav"> <a class="el" href="dir_000000.html">home</a> / <a class="el" href="dir_000001.html">oden</a> / <a class="el" href="dir_000002.html">RPM</a> / <a class="el" href="dir_000003.html">BUILD</a> / <a class="el" href="dir_000004.html">apr-1.1.1</a> / <a class="el" href="dir_000005.html">include</a></div> <h1>apr_network_io.h</h1><a href="apr__network__io_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 <span class="comment">/* Copyright 2000-2004 The Apache Software Foundation</span> 00002 <span class="comment"> *</span> 00003 <span class="comment"> * Licensed under the Apache License, Version 2.0 (the "License");</span> 00004 <span class="comment"> * you may not use this file except in compliance with the License.</span> 00005 <span class="comment"> * You may obtain a copy of the License at</span> 00006 <span class="comment"> *</span> 00007 <span class="comment"> * http://www.apache.org/licenses/LICENSE-2.0</span> 00008 <span class="comment"> *</span> 00009 <span class="comment"> * Unless required by applicable law or agreed to in writing, software</span> 00010 <span class="comment"> * distributed under the License is distributed on an "AS IS" BASIS,</span> 00011 <span class="comment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span> 00012 <span class="comment"> * See the License for the specific language governing permissions and</span> 00013 <span class="comment"> * limitations under the License.</span> 00014 <span class="comment"> */</span> 00015 00016 <span class="preprocessor">#ifndef APR_NETWORK_IO_H</span> 00017 <span class="preprocessor"></span><span class="preprocessor">#define APR_NETWORK_IO_H</span> 00018 <span class="preprocessor"></span><span class="comment">/**</span> 00019 <span class="comment"> * @file apr_network_io.h</span> 00020 <span class="comment"> * @brief APR Network library</span> 00021 <span class="comment"> */</span> 00022 00023 <span class="preprocessor">#include "<a class="code" href="apr_8h.html">apr.h</a>"</span> 00024 <span class="preprocessor">#include "<a class="code" href="apr__pools_8h.html">apr_pools.h</a>"</span> 00025 <span class="preprocessor">#include "<a class="code" href="apr__file__io_8h.html">apr_file_io.h</a>"</span> 00026 <span class="preprocessor">#include "<a class="code" href="apr__errno_8h.html">apr_errno.h</a>"</span> 00027 <span class="preprocessor">#include "<a class="code" href="apr__inherit_8h.html">apr_inherit.h</a>"</span> 00028 00029 <span class="preprocessor">#if APR_HAVE_NETINET_IN_H</span> 00030 <span class="preprocessor"></span><span class="preprocessor">#include <netinet/in.h></span> 00031 <span class="preprocessor">#endif</span> 00032 <span class="preprocessor"></span> 00033 <span class="preprocessor">#ifdef __cplusplus</span> 00034 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="stringliteral">"C"</span> { 00035 <span class="preprocessor">#endif </span><span class="comment">/* __cplusplus */</span> 00036 <span class="comment"></span> 00037 <span class="comment">/**</span> 00038 <span class="comment"> * @defgroup apr_network_io Network Routines</span> 00039 <span class="comment"> * @ingroup APR </span> 00040 <span class="comment"> * @{</span> 00041 <span class="comment"> */</span> 00042 00043 <span class="preprocessor">#ifndef APR_MAX_SECS_TO_LINGER</span> 00044 <span class="preprocessor"></span><span class="comment">/** Maximum seconds to linger */</span> <a name="l00045"></a><a class="code" href="group__apr__network__io.html#ga41">00045</a> <span class="preprocessor">#define APR_MAX_SECS_TO_LINGER 30</span> 00046 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 00047 <span class="preprocessor"></span> 00048 <span class="preprocessor">#ifndef APRMAXHOSTLEN</span> 00049 <span class="preprocessor"></span><span class="comment">/** Maximum hostname length */</span> <a name="l00050"></a><a class="code" href="group__apr__network__io.html#ga42">00050</a> <span class="preprocessor">#define APRMAXHOSTLEN 256</span> 00051 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 00052 <span class="preprocessor"></span> 00053 <span class="preprocessor">#ifndef APR_ANYADDR</span> 00054 <span class="preprocessor"></span><span class="comment">/** Default 'any' address */</span> <a name="l00055"></a><a class="code" href="group__apr__network__io.html#ga43">00055</a> <span class="preprocessor">#define APR_ANYADDR "0.0.0.0"</span> 00056 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 00057 <span class="preprocessor"></span><span class="comment"></span> 00058 <span class="comment">/**</span> 00059 <span class="comment"> * @defgroup apr_sockopt Socket option definitions</span> 00060 <span class="comment"> * @{</span> 00061 <span class="comment"> */</span> <a name="l00062"></a><a class="code" href="group__apr__sockopt.html#ga0">00062</a> <span class="preprocessor">#define APR_SO_LINGER 1 </span><span class="comment">/**< Linger */</span> <a name="l00063"></a><a class="code" href="group__apr__sockopt.html#ga1">00063</a> <span class="preprocessor">#define APR_SO_KEEPALIVE 2 </span><span class="comment">/**< Keepalive */</span> <a name="l00064"></a><a class="code" href="group__apr__sockopt.html#ga2">00064</a> <span class="preprocessor">#define APR_SO_DEBUG 4 </span><span class="comment">/**< Debug */</span> <a name="l00065"></a><a class="code" href="group__apr__sockopt.html#ga3">00065</a> <span class="preprocessor">#define APR_SO_NONBLOCK 8 </span><span class="comment">/**< Non-blocking IO */</span> <a name="l00066"></a><a class="code" href="group__apr__sockopt.html#ga4">00066</a> <span class="preprocessor">#define APR_SO_REUSEADDR 16 </span><span class="comment">/**< Reuse addresses */</span> <a name="l00067"></a><a class="code" href="group__apr__sockopt.html#ga5">00067</a> <span class="preprocessor">#define APR_SO_SNDBUF 64 </span><span class="comment">/**< Send buffer */</span> <a name="l00068"></a><a class="code" href="group__apr__sockopt.html#ga6">00068</a> <span class="preprocessor">#define APR_SO_RCVBUF 128 </span><span class="comment">/**< Receive buffer */</span> <a name="l00069"></a><a class="code" href="group__apr__sockopt.html#ga7">00069</a> <span class="preprocessor">#define APR_SO_DISCONNECTED 256 </span><span class="comment">/**< Disconnected */</span> <a name="l00070"></a><a class="code" href="group__apr__sockopt.html#ga8">00070</a> <span class="preprocessor">#define APR_TCP_NODELAY 512 </span><span class="comment">/**< For SCTP sockets, this is mapped</span> 00071 <span class="comment"> * to STCP_NODELAY internally.</span> 00072 <span class="comment"> */</span> <a name="l00073"></a><a class="code" href="group__apr__sockopt.html#ga9">00073</a> <span class="preprocessor">#define APR_TCP_NOPUSH 1024 </span><span class="comment">/**< No push */</span> <a name="l00074"></a><a class="code" href="group__apr__sockopt.html#ga10">00074</a> <span class="preprocessor">#define APR_RESET_NODELAY 2048 </span><span class="comment">/**< This flag is ONLY set internally</span> 00075 <span class="comment"> * when we set APR_TCP_NOPUSH with</span> 00076 <span class="comment"> * APR_TCP_NODELAY set to tell us that</span> 00077 <span class="comment"> * APR_TCP_NODELAY should be turned on</span> 00078 <span class="comment"> * again when NOPUSH is turned off</span> 00079 <span class="comment"> */</span> <a name="l00080"></a><a class="code" href="group__apr__sockopt.html#ga11">00080</a> <span class="preprocessor">#define APR_INCOMPLETE_READ 4096 </span><span class="comment">/**< Set on non-blocking sockets</span> 00081 <span class="comment"> * (timeout != 0) on which the</span> 00082 <span class="comment"> * previous read() did not fill a buffer</span> 00083 <span class="comment"> * completely. the next apr_socket_recv() </span> 00084 <span class="comment"> * will first call select()/poll() rather than</span> 00085 <span class="comment"> * going straight into read(). (Can also</span> 00086 <span class="comment"> * be set by an application to force a</span> 00087 <span class="comment"> * select()/poll() call before the next</span> 00088 <span class="comment"> * read, in cases where the app expects</span> 00089 <span class="comment"> * that an immediate read would fail.)</span> 00090 <span class="comment"> */</span> <a name="l00091"></a><a class="code" href="group__apr__sockopt.html#ga12">00091</a> <span class="preprocessor">#define APR_INCOMPLETE_WRITE 8192 </span><span class="comment">/**< like APR_INCOMPLETE_READ, but for write</span> 00092 <span class="comment"> * @see APR_INCOMPLETE_READ</span> 00093 <span class="comment"> */</span> <a name="l00094"></a><a class="code" href="group__apr__sockopt.html#ga13">00094</a> <span class="preprocessor">#define APR_IPV6_V6ONLY 16384 </span><span class="comment">/**< Don't accept IPv4 connections on an</span> 00095 <span class="comment"> * IPv6 listening socket.</span> 00096 <span class="comment"> */</span> <a name="l00097"></a><a class="code" href="group__apr__sockopt.html#ga14">00097</a> <span class="preprocessor">#define APR_TCP_DEFER_ACCEPT 32768 </span><span class="comment">/**< Delay accepting of new connections </span> 00098 <span class="comment"> * until data is available.</span> 00099 <span class="comment"> * @see apr_socket_accept_filter</span> 00100 <span class="comment"> */</span> 00101 <span class="comment"></span> 00102 <span class="comment">/** @} */</span> 00103 <span class="comment"></span> 00104 <span class="comment">/** Define what type of socket shutdown should occur. */</span> <a name="l00105"></a><a class="code" href="group__apr__network__io.html#ga52">00105</a> <span class="keyword">typedef</span> <span class="keyword">enum</span> { 00106 APR_SHUTDOWN_READ, <span class="comment">/**< no longer allow read request */</span> 00107 APR_SHUTDOWN_WRITE, <span class="comment">/**< no longer allow write requests */</span> 00108 <a class="code" href="group__apr__network__io.html#gga52a37">APR_SHUTDOWN_READWRITE</a> <span class="comment">/**< no longer allow read or write requests */</span> 00109 } apr_shutdown_how_e; 00110 <a name="l00111"></a><a class="code" href="group__apr__network__io.html#ga44">00111</a> <span class="preprocessor">#define APR_IPV4_ADDR_OK 0x01 </span><span class="comment">/**< @see apr_sockaddr_info_get() */</span> <a name="l00112"></a><a class="code" href="group__apr__network__io.html#ga45">00112</a> <span class="preprocessor">#define APR_IPV6_ADDR_OK 0x02 </span><span class="comment">/**< @see apr_sockaddr_info_get() */</span> 00113 00114 <span class="preprocessor">#if (!APR_HAVE_IN_ADDR)</span> 00115 <span class="preprocessor"></span><span class="comment">/**</span> 00116 <span class="comment"> * We need to make sure we always have an in_addr type, so APR will just</span> 00117 <span class="comment"> * define it ourselves, if the platform doesn't provide it.</span> 00118 <span class="comment"> */</span> 00119 <span class="keyword">struct </span>in_addr { 00120 apr_uint32_t s_addr; <span class="comment">/**< storage to hold the IP# */</span> 00121 }; 00122 <span class="preprocessor">#endif</span> 00123 <span class="preprocessor"></span><span class="comment"></span> 00124 <span class="comment">/** @def APR_INADDR_NONE</span> 00125 <span class="comment"> * Not all platforms have a real INADDR_NONE. This macro replaces</span> 00126 <span class="comment"> * INADDR_NONE on all platforms.</span> 00127 <span class="comment"> */</span> 00128 <span class="preprocessor">#ifdef INADDR_NONE</span> 00129 <span class="preprocessor"></span><span class="preprocessor">#define APR_INADDR_NONE INADDR_NONE</span> 00130 <span class="preprocessor"></span><span class="preprocessor">#else</span> <a name="l00131"></a><a class="code" href="group__apr__network__io.html#ga46">00131</a> <span class="preprocessor"></span><span class="preprocessor">#define APR_INADDR_NONE ((unsigned int) 0xffffffff)</span> 00132 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 00133 <span class="preprocessor"></span><span class="comment"></span> 00134 <span class="comment">/**</span> 00135 <span class="comment"> * @def APR_INET</span> 00136 <span class="comment"> * Not all platforms have these defined, so we'll define them here</span> 00137 <span class="comment"> * The default values come from FreeBSD 4.1.1</span> 00138 <span class="comment"> */</span> <a name="l00139"></a><a class="code" href="group__apr__network__io.html#ga47">00139</a> <span class="preprocessor">#define APR_INET AF_INET</span> 00140 <span class="preprocessor"></span><span class="comment">/** @def APR_UNSPEC</span> 00141 <span class="comment"> * Let the system decide which address family to use</span> 00142 <span class="comment"> */</span> 00143 <span class="preprocessor">#ifdef AF_UNSPEC</span> 00144 <span class="preprocessor"></span><span class="preprocessor">#define APR_UNSPEC AF_UNSPEC</span> 00145 <span class="preprocessor"></span><span class="preprocessor">#else</span> <a name="l00146"></a><a class="code" href="group__apr__network__io.html#ga48">00146</a> <span class="preprocessor"></span><span class="preprocessor">#define APR_UNSPEC 0</span> 00147 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 00148 <span class="preprocessor"></span><span class="preprocessor">#if APR_HAVE_IPV6</span> 00149 <span class="preprocessor"></span><span class="comment">/** @def APR_INET6</span> 00150 <span class="comment">* IPv6 Address Family. Not all platforms may have this defined.</span> 00151 <span class="comment">*/</span> 00152 <a name="l00153"></a><a class="code" href="group__apr__network__io.html#ga49">00153</a> <span class="preprocessor">#define APR_INET6 AF_INET6</span> 00154 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 00155 <span class="preprocessor"></span><span class="comment"></span> 00156 <span class="comment">/**</span> 00157 <span class="comment"> * @defgroup IP_Proto IP Protocol Definitions for use when creating sockets</span> 00158 <span class="comment"> * @{</span> 00159 <span class="comment"> */</span> <a name="l00160"></a><a class="code" href="group__IP__Proto.html#ga0">00160</a> <span class="preprocessor">#define APR_PROTO_TCP 6 </span><span class="comment">/**< TCP */</span> <a name="l00161"></a><a class="code" href="group__IP__Proto.html#ga1">00161</a> <span class="preprocessor">#define APR_PROTO_UDP 17 </span><span class="comment">/**< UDP */</span> <a name="l00162"></a><a class="code" href="group__IP__Proto.html#ga2">00162</a> <span class="preprocessor">#define APR_PROTO_SCTP 132 </span><span class="comment">/**< SCTP */</span> 00163 <span class="comment">/** @} */</span> 00164 <span class="comment"></span> 00165 <span class="comment">/**</span> 00166 <span class="comment"> * Enum to tell us if we're interested in remote or local socket</span> 00167 <span class="comment"> */</span> <a name="l00168"></a><a class="code" href="group__apr__network__io.html#ga53">00168</a> <span class="keyword">typedef</span> <span class="keyword">enum</span> { 00169 APR_LOCAL, 00170 APR_REMOTE 00171 } apr_interface_e; 00172 <span class="comment"></span> 00173 <span class="comment">/**</span> 00174 <span class="comment"> * The specific declaration of inet_addr's ... some platforms fall back</span> 00175 <span class="comment"> * inet_network (this is not good, but necessary)</span> 00176 <span class="comment"> */</span> 00177 00178 <span class="preprocessor">#if APR_HAVE_INET_ADDR</span> <a name="l00179"></a><a class="code" href="group__apr__network__io.html#ga50">00179</a> <span class="preprocessor"></span><span class="preprocessor">#define apr_inet_addr inet_addr</span> 00180 <span class="preprocessor"></span><span class="preprocessor">#elif APR_HAVE_INET_NETWORK </span><span class="comment">/* only DGUX, as far as I know */</span> 00181 <span class="comment">/**</span> 00182 <span class="comment"> * @warning</span> 00183 <span class="comment"> * not generally safe... inet_network() and inet_addr() perform</span> 00184 <span class="comment"> * different functions */</span> 00185 <span class="preprocessor">#define apr_inet_addr inet_network</span> 00186 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 00187 <span class="preprocessor"></span><span class="comment"></span> 00188 <span class="comment">/** A structure to represent sockets */</span> <a name="l00189"></a><a class="code" href="group__apr__network__io.html#ga0">00189</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="group__apr__network__io.html#ga0">apr_socket_t</a> <a class="code" href="group__apr__network__io.html#ga0">apr_socket_t</a>;<span class="comment"></span> 00190 <span class="comment">/**</span> 00191 <span class="comment"> * A structure to encapsulate headers and trailers for apr_socket_sendfile</span> 00192 <span class="comment"> */</span> <a name="l00193"></a><a class="code" href="group__apr__network__io.html#ga1">00193</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structapr__hdtr__t.html">apr_hdtr_t</a> <a class="code" href="group__apr__network__io.html#ga1">apr_hdtr_t</a>;<span class="comment"></span> 00194 <span class="comment">/** A structure to represent in_addr */</span> <a name="l00195"></a><a class="code" href="group__apr__network__io.html#ga2">00195</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>in_addr <a class="code" href="group__apr__network__io.html#ga2">apr_in_addr_t</a>;<span class="comment"></span> 00196 <span class="comment">/** A structure to represent an IP subnet */</span> <a name="l00197"></a><a class="code" href="group__apr__network__io.html#ga3">00197</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="group__apr__network__io.html#ga3">apr_ipsubnet_t</a> <a class="code" href="group__apr__network__io.html#ga3">apr_ipsubnet_t</a>; 00198 <span class="comment"></span> 00199 <span class="comment">/** @remark use apr_uint16_t just in case some system has a short that isn't 16 bits... */</span> <a name="l00200"></a><a class="code" href="group__apr__network__io.html#ga4">00200</a> <span class="keyword">typedef</span> apr_uint16_t apr_port_t; 00201 <span class="comment"></span> 00202 <span class="comment">/** @remark It's defined here as I think it should all be platform safe...</span> 00203 <span class="comment"> * @see apr_sockaddr_t</span> 00204 <span class="comment"> */</span> <a name="l00205"></a><a class="code" href="group__apr__network__io.html#ga5">00205</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structapr__sockaddr__t.html">apr_sockaddr_t</a> <a class="code" href="group__apr__network__io.html#ga5">apr_sockaddr_t</a>;<span class="comment"></span> 00206 <span class="comment">/**</span> 00207 <span class="comment"> * APRs socket address type, used to ensure protocol independence</span> 00208 <span class="comment"> */</span> <a name="l00209"></a><a class="code" href="structapr__sockaddr__t.html">00209</a> <span class="keyword">struct </span><a class="code" href="group__apr__network__io.html#ga5">apr_sockaddr_t</a> {<span class="comment"></span> 00210 <span class="comment"> /** The pool to use... */</span> <a name="l00211"></a><a class="code" href="structapr__sockaddr__t.html#o0">00211</a> <a class="code" href="group__apr__pools.html#ga0">apr_pool_t</a> *pool;<span class="comment"></span> 00212 <span class="comment"> /** The hostname */</span> <a name="l00213"></a><a class="code" href="structapr__sockaddr__t.html#o1">00213</a> <span class="keywordtype">char</span> *hostname;<span class="comment"></span> 00214 <span class="comment"> /** Either a string of the port number or the service name for the port */</span> <a name="l00215"></a><a class="code" href="structapr__sockaddr__t.html#o2">00215</a> <span class="keywordtype">char</span> *servname;<span class="comment"></span> 00216 <span class="comment"> /** The numeric port */</span> <a name="l00217"></a><a class="code" href="structapr__sockaddr__t.html#o3">00217</a> <a class="code" href="group__apr__network__io.html#ga4">apr_port_t</a> port;<span class="comment"></span> 00218 <span class="comment"> /** The family */</span> <a name="l00219"></a><a class="code" href="structapr__sockaddr__t.html#o4">00219</a> apr_int32_t family;<span class="comment"></span> 00220 <span class="comment"> /** How big is the sockaddr we're using? */</span> <a name="l00221"></a><a class="code" href="structapr__sockaddr__t.html#o5">00221</a> apr_socklen_t salen;<span class="comment"></span> 00222 <span class="comment"> /** How big is the ip address structure we're using? */</span> <a name="l00223"></a><a class="code" href="structapr__sockaddr__t.html#o6">00223</a> <span class="keywordtype">int</span> ipaddr_len;<span class="comment"></span> 00224 <span class="comment"> /** How big should the address buffer be? 16 for v4 or 46 for v6</span> 00225 <span class="comment"> * used in inet_ntop... */</span> <a name="l00226"></a><a class="code" href="structapr__sockaddr__t.html#o7">00226</a> <span class="keywordtype">int</span> addr_str_len;<span class="comment"></span> 00227 <span class="comment"> /** This points to the IP address structure within the appropriate</span> 00228 <span class="comment"> * sockaddr structure. */</span> <a name="l00229"></a><a class="code" href="structapr__sockaddr__t.html#o8">00229</a> <span class="keywordtype">void</span> *ipaddr_ptr;<span class="comment"></span> 00230 <span class="comment"> /** If multiple addresses were found by apr_sockaddr_info_get(), this </span> 00231 <span class="comment"> * points to a representation of the next address. */</span> <a name="l00232"></a><a class="code" href="structapr__sockaddr__t.html#o9">00232</a> <a class="code" href="group__apr__network__io.html#ga5">apr_sockaddr_t</a> *next;<span class="comment"></span> 00233 <span class="comment"> /** Union of either IPv4 or IPv6 sockaddr. */</span> 00234 <span class="keyword">union </span>{<span class="comment"></span> 00235 <span class="comment"> /** IPv4 sockaddr structure */</span> <a name="l00236"></a><a class="code" href="structapr__sockaddr__t.html#o10">00236</a> <span class="keyword">struct </span>sockaddr_in sin; 00237 <span class="preprocessor">#if APR_HAVE_IPV6</span> 00238 <span class="preprocessor"></span><span class="comment"> /** IPv6 sockaddr structure */</span> <a name="l00239"></a><a class="code" href="structapr__sockaddr__t.html#o11">00239</a> <span class="keyword">struct </span>sockaddr_in6 sin6; 00240 <span class="preprocessor">#endif</span> 00241 <span class="preprocessor"></span><span class="preprocessor">#if APR_HAVE_SA_STORAGE</span> 00242 <span class="preprocessor"></span><span class="comment"> /** Placeholder to ensure that the size of this union is not</span> 00243 <span class="comment"> * dependent on whether APR_HAVE_IPV6 is defined. */</span> <a name="l00244"></a><a class="code" href="structapr__sockaddr__t.html#o12">00244</a> <span class="keyword">struct </span>sockaddr_storage sas; 00245 <span class="preprocessor">#endif</span> 00246 <span class="preprocessor"></span> } sa; 00247 }; 00248 00249 <span class="preprocessor">#if APR_HAS_SENDFILE</span> 00250 <span class="preprocessor"></span><span class="comment">/** </span> 00251 <span class="comment"> * Support reusing the socket on platforms which support it (from disconnect,</span> 00252 <span class="comment"> * specifically Win32.</span> 00253 <span class="comment"> * @remark Optional flag passed into apr_socket_sendfile() </span> 00254 <span class="comment"> */</span> <a name="l00255"></a><a class="code" href="group__apr__network__io.html#ga51">00255</a> <span class="preprocessor">#define APR_SENDFILE_DISCONNECT_SOCKET 1</span> 00256 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 00257 <span class="preprocessor"></span><span class="comment"></span> 00258 <span class="comment">/** A structure to encapsulate headers and trailers for apr_socket_sendfile */</span> <a name="l00259"></a><a class="code" href="structapr__hdtr__t.html">00259</a> <span class="keyword">struct </span><a class="code" href="group__apr__network__io.html#ga1">apr_hdtr_t</a> {<span class="comment"></span> 00260 <span class="comment"> /** An iovec to store the headers sent before the file. */</span> <a name="l00261"></a><a class="code" href="structapr__hdtr__t.html#o0">00261</a> <span class="keyword">struct </span>iovec* headers;<span class="comment"></span> 00262 <span class="comment"> /** number of headers in the iovec */</span> <a name="l00263"></a><a class="code" href="structapr__hdtr__t.html#o1">00263</a> <span class="keywordtype">int</span> numheaders;<span class="comment"></span> 00264 <span class="comment"> /** An iovec to store the trailers sent after the file. */</span> <a name="l00265"></a><a class="code" href="structapr__hdtr__t.html#o2">00265</a> <span class="keyword">struct </span>iovec* trailers;<span class="comment"></span> 00266 <span class="comment"> /** number of trailers in the iovec */</span> <a name="l00267"></a><a class="code" href="structapr__hdtr__t.html#o3">00267</a> <span class="keywordtype">int</span> numtrailers; 00268 }; 00269 00270 <span class="comment">/* function definitions */</span> 00271 <span class="comment"></span> 00272 <span class="comment">/**</span> 00273 <span class="comment"> * Create a socket.</span> 00274 <span class="comment"> * @param new_sock The new socket that has been set up.</span> 00275 <span class="comment"> * @param family The address family of the socket (e.g., APR_INET).</span> 00276 <span class="comment"> * @param type The type of the socket (e.g., SOCK_STREAM).</span> 00277 <span class="comment"> * @param protocol The protocol of the socket (e.g., APR_PROTO_TCP).</span> 00278 <span class="comment"> * @param cont The pool to use</span> 00279 <span class="comment"> */</span> 00280 <a class="code" href="group__apr__platform.html#ga123">APR_DECLARE</a>(apr_status_t) apr_socket_create(apr_socket_t **new_sock, 00281 <span class="keywordtype">int</span> family, <span class="keywordtype">int</span> type, 00282 <span class="keywordtype">int</span> protocol, 00283 apr_pool_t *cont); 00284 <span class="comment"></span> 00285 <span class="comment">/**</span> 00286 <span class="comment"> * Shutdown either reading, writing, or both sides of a socket.</span> 00287 <span class="comment"> * @param thesocket The socket to close </span> 00288 <span class="comment"> * @param how How to shutdown the socket. One of:</span> 00289 <span class="comment"> * <PRE></span> 00290 <span class="comment"> * APR_SHUTDOWN_READ no longer allow read requests</span> 00291 <span class="comment"> * APR_SHUTDOWN_WRITE no longer allow write requests</span> 00292 <span class="comment"> * APR_SHUTDOWN_READWRITE no longer allow read or write requests </span> 00293 <span class="comment"> * </PRE></span> 00294 <span class="comment"> * @see apr_shutdown_how_e</span> 00295 <span class="comment"> * @remark This does not actually close the socket descriptor, it just</span> 00296 <span class="comment"> * controls which calls are still valid on the socket.</span> 00297 <span class="comment"> */</span> 00298 APR_DECLARE(apr_status_t) apr_socket_shutdown(apr_socket_t *thesocket, 00299 apr_shutdown_how_e how); 00300 <span class="comment"></span> 00301 <span class="comment">/**</span> 00302 <span class="comment"> * Close a socket.</span> 00303 <span class="comment"> * @param thesocket The socket to close </span> 00304 <span class="comment"> */</span> 00305 APR_DECLARE(apr_status_t) apr_socket_close(apr_socket_t *thesocket); 00306 <span class="comment"></span> 00307 <span class="comment">/**</span> 00308 <span class="comment"> * Bind the socket to its associated port</span> 00309 <span class="comment"> * @param sock The socket to bind </span> 00310 <span class="comment"> * @param sa The socket address to bind to</span> 00311 <span class="comment"> * @remark This may be where we will find out if there is any other process</span> 00312 <span class="comment"> * using the selected port.</span> 00313 <span class="comment"> */</span> 00314 APR_DECLARE(apr_status_t) apr_socket_bind(apr_socket_t *sock, 00315 apr_sockaddr_t *sa); 00316 <span class="comment"></span> 00317 <span class="comment">/**</span> 00318 <span class="comment"> * Listen to a bound socket for connections.</span> 00319 <span class="comment"> * @param sock The socket to listen on </span> 00320 <span class="comment"> * @param backlog The number of outstanding connections allowed in the sockets</span> 00321 <span class="comment"> * listen queue. If this value is less than zero, the listen</span> 00322 <span class="comment"> * queue size is set to zero. </span> 00323 <span class="comment"> */</span> 00324 APR_DECLARE(apr_status_t) apr_socket_listen(apr_socket_t *sock, 00325 apr_int32_t backlog); 00326 <span class="comment"></span> 00327 <span class="comment">/**</span> 00328 <span class="comment"> * Accept a new connection request</span> 00329 <span class="comment"> * @param new_sock A copy of the socket that is connected to the socket that</span> 00330 <span class="comment"> * made the connection request. This is the socket which should</span> 00331 <span class="comment"> * be used for all future communication.</span> 00332 <span class="comment"> * @param sock The socket we are listening on.</span> 00333 <span class="comment"> * @param connection_pool The pool for the new socket.</span> 00334 <span class="comment"> */</span> 00335 APR_DECLARE(apr_status_t) apr_socket_accept(apr_socket_t **new_sock, 00336 apr_socket_t *sock, 00337 apr_pool_t *connection_pool); 00338 <span class="comment"></span> 00339 <span class="comment">/**</span> 00340 <span class="comment"> * Issue a connection request to a socket either on the same machine </span> 00341 <span class="comment"> * or a different one.</span> 00342 <span class="comment"> * @param sock The socket we wish to use for our side of the connection </span> 00343 <span class="comment"> * @param sa The address of the machine we wish to connect to.</span> 00344 <span class="comment"> */</span> 00345 APR_DECLARE(apr_status_t) apr_socket_connect(apr_socket_t *sock, 00346 apr_sockaddr_t *sa); 00347 <span class="comment"></span> 00348 <span class="comment">/**</span> 00349 <span class="comment"> * Create apr_sockaddr_t from hostname, address family, and port.</span> 00350 <span class="comment"> * @param sa The new apr_sockaddr_t.</span> 00351 <span class="comment"> * @param hostname The hostname or numeric address string to resolve/parse, or</span> 00352 <span class="comment"> * NULL to build an address that corresponds to 0.0.0.0 or ::</span> 00353 <span class="comment"> * @param family The address family to use, or APR_UNSPEC if the system should </span> 00354 <span class="comment"> * decide.</span> 00355 <span class="comment"> * @param port The port number.</span> 00356 <span class="comment"> * @param flags Special processing flags:</span> 00357 <span class="comment"> * <PRE></span> 00358 <span class="comment"> * APR_IPV4_ADDR_OK first query for IPv4 addresses; only look</span> 00359 <span class="comment"> * for IPv6 addresses if the first query failed;</span> 00360 <span class="comment"> * only valid if family is APR_UNSPEC and hostname</span> 00361 <span class="comment"> * isn't NULL; mutually exclusive with</span> 00362 <span class="comment"> * APR_IPV6_ADDR_OK</span> 00363 <span class="comment"> * APR_IPV6_ADDR_OK first query for IPv6 addresses; only look</span> 00364 <span class="comment"> * for IPv4 addresses if the first query failed;</span> 00365 <span class="comment"> * only valid if family is APR_UNSPEC and hostname</span> 00366 <span class="comment"> * isn't NULL and APR_HAVE_IPV6; mutually exclusive</span> 00367 <span class="comment"> * with APR_IPV4_ADDR_OK</span> 00368 <span class="comment"> * </PRE></span> 00369 <span class="comment"> * @param p The pool for the apr_sockaddr_t and associated storage.</span> 00370 <span class="comment"> */</span> 00371 APR_DECLARE(apr_status_t) apr_sockaddr_info_get(apr_sockaddr_t **sa, 00372 const <span class="keywordtype">char</span> *hostname, 00373 apr_int32_t family, 00374 apr_port_t port, 00375 apr_int32_t flags, 00376 apr_pool_t *p); 00377 <span class="comment"></span> 00378 <span class="comment">/**</span> 00379 <span class="comment"> * Look up the host name from an apr_sockaddr_t.</span> 00380 <span class="comment"> * @param hostname The hostname.</span> 00381 <span class="comment"> * @param sa The apr_sockaddr_t.</span> 00382 <span class="comment"> * @param flags Special processing flags.</span> 00383 <span class="comment"> */</span> 00384 APR_DECLARE(apr_status_t) apr_getnameinfo(<span class="keywordtype">char</span> **hostname, 00385 apr_sockaddr_t *sa, 00386 apr_int32_t flags); 00387 <span class="comment"></span> 00388 <span class="comment">/**</span> 00389 <span class="comment"> * Parse hostname/IP address with scope id and port.</span> 00390 <span class="comment"> *</span> 00391 <span class="comment"> * Any of the following strings are accepted:</span> 00392 <span class="comment"> * 8080 (just the port number)</span> 00393 <span class="comment"> * www.apache.org (just the hostname)</span> 00394 <span class="comment"> * www.apache.org:8080 (hostname and port number)</span> 00395 <span class="comment"> * [fe80::1]:80 (IPv6 numeric address string only)</span> 00396 <span class="comment"> * [fe80::1%eth0] (IPv6 numeric address string and scope id)</span> 00397 <span class="comment"> *</span> 00398 <span class="comment"> * Invalid strings:</span> 00399 <span class="comment"> * (empty string)</span> 00400 <span class="comment"> * [abc] (not valid IPv6 numeric address string)</span> 00401 <span class="comment"> * abc:65536 (invalid port number)</span> 00402 <span class="comment"> *</span> 00403 <span class="comment"> * @param addr The new buffer containing just the hostname. On output, *addr </span> 00404 <span class="comment"> * will be NULL if no hostname/IP address was specfied.</span> 00405 <span class="comment"> * @param scope_id The new buffer containing just the scope id. On output, </span> 00406 <span class="comment"> * *scope_id will be NULL if no scope id was specified.</span> 00407 <span class="comment"> * @param port The port number. On output, *port will be 0 if no port was </span> 00408 <span class="comment"> * specified.</span> 00409 <span class="comment"> * ### FIXME: 0 is a legal port (per RFC 1700). this should</span> 00410 <span class="comment"> * ### return something besides zero if the port is missing.</span> 00411 <span class="comment"> * @param str The input string to be parsed.</span> 00412 <span class="comment"> * @param p The pool from which *addr and *scope_id are allocated.</span> 00413 <span class="comment"> * @remark If scope id shouldn't be allowed, check for scope_id != NULL in </span> 00414 <span class="comment"> * addition to checking the return code. If addr/hostname should be </span> 00415 <span class="comment"> * required, check for addr == NULL in addition to checking the </span> 00416 <span class="comment"> * return code.</span> 00417 <span class="comment"> */</span> 00418 APR_DECLARE(apr_status_t) apr_parse_addr_port(<span class="keywordtype">char</span> **addr, 00419 <span class="keywordtype">char</span> **scope_id, 00420 apr_port_t *port, 00421 const <span class="keywordtype">char</span> *str, 00422 apr_pool_t *p); 00423 <span class="comment"></span> 00424 <span class="comment">/**</span> 00425 <span class="comment"> * Get name of the current machine</span> 00426 <span class="comment"> * @param buf A buffer to store the hostname in.</span> 00427 <span class="comment"> * @param len The maximum length of the hostname that can be stored in the</span> 00428 <span class="comment"> * buffer provided. The suggested length is APRMAXHOSTLEN + 1.</span> 00429 <span class="comment"> * @param cont The pool to use.</span> 00430 <span class="comment"> * @remark If the buffer was not large enough, an error will be returned.</span> 00431 <span class="comment"> */</span> 00432 APR_DECLARE(apr_status_t) apr_gethostname(<span class="keywordtype">char</span> *buf, <span class="keywordtype">int</span> len, apr_pool_t *cont); 00433 <span class="comment"></span> 00434 <span class="comment">/**</span> 00435 <span class="comment"> * Return the data associated with the current socket</span> 00436 <span class="comment"> * @param data The user data associated with the socket.</span> 00437 <span class="comment"> * @param key The key to associate with the user data.</span> 00438 <span class="comment"> * @param sock The currently open socket.</span> 00439 <span class="comment"> */</span> 00440 APR_DECLARE(apr_status_t) apr_socket_data_get(<span class="keywordtype">void</span> **data, const <span class="keywordtype">char</span> *key, 00441 apr_socket_t *sock); 00442 <span class="comment"></span> 00443 <span class="comment">/**</span> 00444 <span class="comment"> * Set the data associated with the current socket.</span> 00445 <span class="comment"> * @param sock The currently open socket.</span> 00446 <span class="comment"> * @param data The user data to associate with the socket.</span> 00447 <span class="comment"> * @param key The key to associate with the data.</span> 00448 <span class="comment"> * @param cleanup The cleanup to call when the socket is destroyed.</span> 00449 <span class="comment"> */</span> 00450 APR_DECLARE(apr_status_t) apr_socket_data_set(apr_socket_t *sock, <span class="keywordtype">void</span> *data, 00451 const <span class="keywordtype">char</span> *key, 00452 apr_status_t (*cleanup)(<span class="keywordtype">void</span>*)); 00453 <span class="comment"></span> 00454 <span class="comment">/**</span> 00455 <span class="comment"> * Send data over a network.</span> 00456 <span class="comment"> * @param sock The socket to send the data over.</span> 00457 <span class="comment"> * @param buf The buffer which contains the data to be sent. </span> 00458 <span class="comment"> * @param len On entry, the number of bytes to send; on exit, the number</span> 00459 <span class="comment"> * of bytes sent.</span> 00460 <span class="comment"> * @remark</span> 00461 <span class="comment"> * <PRE></span> 00462 <span class="comment"> * This functions acts like a blocking write by default. To change </span> 00463 <span class="comment"> * this behavior, use apr_socket_timeout_set() or the APR_SO_NONBLOCK</span> 00464 <span class="comment"> * socket option.</span> 00465 <span class="comment"> *</span> 00466 <span class="comment"> * It is possible for both bytes to be sent and an error to be returned.</span> 00467 <span class="comment"> *</span> 00468 <span class="comment"> * APR_EINTR is never returned.</span> 00469 <span class="comment"> * </PRE></span> 00470 <span class="comment"> */</span> 00471 APR_DECLARE(apr_status_t) apr_socket_send(apr_socket_t *sock, const <span class="keywordtype">char</span> *buf, 00472 apr_size_t *len); 00473 <span class="comment"></span> 00474 <span class="comment">/**</span> 00475 <span class="comment"> * Send multiple packets of data over a network.</span> 00476 <span class="comment"> * @param sock The socket to send the data over.</span> 00477 <span class="comment"> * @param vec The array of iovec structs containing the data to send </span> 00478 <span class="comment"> * @param nvec The number of iovec structs in the array</span> 00479 <span class="comment"> * @param len Receives the number of bytes actually written</span> 00480 <span class="comment"> * @remark</span> 00481 <span class="comment"> * <PRE></span> 00482 <span class="comment"> * This functions acts like a blocking write by default. To change </span> 00483 <span class="comment"> * this behavior, use apr_socket_timeout_set() or the APR_SO_NONBLOCK</span> 00484 <span class="comment"> * socket option.</span> 00485 <span class="comment"> * The number of bytes actually sent is stored in argument 3.</span> 00486 <span class="comment"> *</span> 00487 <span class="comment"> * It is possible for both bytes to be sent and an error to be returned.</span> 00488 <span class="comment"> *</span> 00489 <span class="comment"> * APR_EINTR is never returned.</span> 00490 <span class="comment"> * </PRE></span> 00491 <span class="comment"> */</span> 00492 APR_DECLARE(apr_status_t) apr_socket_sendv(apr_socket_t *sock, 00493 const struct iovec *vec, 00494 apr_int32_t nvec, apr_size_t *len); 00495 <span class="comment"></span> 00496 <span class="comment">/**</span> 00497 <span class="comment"> * @param sock The socket to send from</span> 00498 <span class="comment"> * @param where The apr_sockaddr_t describing where to send the data</span> 00499 <span class="comment"> * @param flags The flags to use</span> 00500 <span class="comment"> * @param buf The data to send</span> 00501 <span class="comment"> * @param len The length of the data to send</span> 00502 <span class="comment"> */</span> 00503 APR_DECLARE(apr_status_t) apr_socket_sendto(apr_socket_t *sock, 00504 apr_sockaddr_t *where, 00505 apr_int32_t flags, const <span class="keywordtype">char</span> *buf, 00506 apr_size_t *len); 00507 <span class="comment"></span> 00508 <span class="comment">/**</span> 00509 <span class="comment"> * @param from The apr_sockaddr_t to fill in the recipient info</span> 00510 <span class="comment"> * @param sock The socket to use</span> 00511 <span class="comment"> * @param flags The flags to use</span> 00512 <span class="comment"> * @param buf The buffer to use</span> 00513 <span class="comment"> * @param len The length of the available buffer</span> 00514 <span class="comment"> */</span> 00515 00516 APR_DECLARE(apr_status_t) apr_socket_recvfrom(apr_sockaddr_t *from, 00517 apr_socket_t *sock, 00518 apr_int32_t flags, <span class="keywordtype">char</span> *buf, 00519 apr_size_t *len); 00520 00521 #if APR_HAS_SENDFILE || defined(DOXYGEN) 00522 <span class="comment"></span> 00523 <span class="comment">/**</span> 00524 <span class="comment"> * Send a file from an open file descriptor to a socket, along with </span> 00525 <span class="comment"> * optional headers and trailers</span> 00526 <span class="comment"> * @param sock The socket to which we're writing</span> 00527 <span class="comment"> * @param file The open file from which to read</span> 00528 <span class="comment"> * @param hdtr A structure containing the headers and trailers to send</span> 00529 <span class="comment"> * @param offset Offset into the file where we should begin writing</span> 00530 <span class="comment"> * @param len (input) - Number of bytes to send from the file </span> 00531 <span class="comment"> * (output) - Number of bytes actually sent, </span> 00532 <span class="comment"> * including headers, file, and trailers</span> 00533 <span class="comment"> * @param flags APR flags that are mapped to OS specific flags</span> 00534 <span class="comment"> * @remark This functions acts like a blocking write by default. To change </span> 00535 <span class="comment"> * this behavior, use apr_socket_timeout_set() or the</span> 00536 <span class="comment"> * APR_SO_NONBLOCK socket option.</span> 00537 <span class="comment"> * The number of bytes actually sent is stored in the len parameter.</span> 00538 <span class="comment"> * The offset parameter is passed by reference for no reason; its</span> 00539 <span class="comment"> * value will never be modified by the apr_socket_sendfile() function.</span> 00540 <span class="comment"> */</span> 00541 APR_DECLARE(apr_status_t) apr_socket_sendfile(apr_socket_t *sock, 00542 apr_file_t *file, 00543 apr_hdtr_t *hdtr, 00544 apr_off_t *offset, 00545 apr_size_t *len, 00546 apr_int32_t flags); 00547 00548 #endif <span class="comment">/* APR_HAS_SENDFILE */</span> 00549 <span class="comment"></span> 00550 <span class="comment">/**</span> 00551 <span class="comment"> * Read data from a network.</span> 00552 <span class="comment"> * @param sock The socket to read the data from.</span> 00553 <span class="comment"> * @param buf The buffer to store the data in. </span> 00554 <span class="comment"> * @param len On entry, the number of bytes to receive; on exit, the number</span> 00555 <span class="comment"> * of bytes received.</span> 00556 <span class="comment"> * @remark</span> 00557 <span class="comment"> * <PRE></span> 00558 <span class="comment"> * This functions acts like a blocking read by default. To change </span> 00559 <span class="comment"> * this behavior, use apr_socket_timeout_set() or the APR_SO_NONBLOCK</span> 00560 <span class="comment"> * socket option.</span> 00561 <span class="comment"> * The number of bytes actually received is stored in argument 3.</span> 00562 <span class="comment"> *</span> 00563 <span class="comment"> * It is possible for both bytes to be received and an APR_EOF or</span> 00564 <span class="comment"> * other error to be returned.</span> 00565 <span class="comment"> *</span> 00566 <span class="comment"> * APR_EINTR is never returned.</span> 00567 <span class="comment"> * </PRE></span> 00568 <span class="comment"> */</span> 00569 APR_DECLARE(apr_status_t) apr_socket_recv(apr_socket_t *sock, 00570 <span class="keywordtype">char</span> *buf, apr_size_t *len); 00571 <span class="comment"></span> 00572 <span class="comment">/**</span> 00573 <span class="comment"> * Setup socket options for the specified socket</span> 00574 <span class="comment"> * @param sock The socket to set up.</span> 00575 <span class="comment"> * @param opt The option we would like to configure. One of:</span> 00576 <span class="comment"> * <PRE></span> 00577 <span class="comment"> * APR_SO_DEBUG -- turn on debugging information </span> 00578 <span class="comment"> * APR_SO_KEEPALIVE -- keep connections active</span> 00579 <span class="comment"> * APR_SO_LINGER -- lingers on close if data is present</span> 00580 <span class="comment"> * APR_SO_NONBLOCK -- Turns blocking on/off for socket</span> 00581 <span class="comment"> * When this option is enabled, use</span> 00582 <span class="comment"> * the APR_STATUS_IS_EAGAIN() macro to</span> 00583 <span class="comment"> * see if a send or receive function</span> 00584 <span class="comment"> * could not transfer data without</span> 00585 <span class="comment"> * blocking.</span> 00586 <span class="comment"> * APR_SO_REUSEADDR -- The rules used in validating addresses</span> 00587 <span class="comment"> * supplied to bind should allow reuse</span> 00588 <span class="comment"> * of local addresses.</span> 00589 <span class="comment"> * APR_SO_SNDBUF -- Set the SendBufferSize</span> 00590 <span class="comment"> * APR_SO_RCVBUF -- Set the ReceiveBufferSize</span> 00591 <span class="comment"> * </PRE></span> 00592 <span class="comment"> * @param on Value for the option.</span> 00593 <span class="comment"> */</span> 00594 APR_DECLARE(apr_status_t) apr_socket_opt_set(apr_socket_t *sock, 00595 apr_int32_t opt, apr_int32_t on); 00596 <span class="comment"></span> 00597 <span class="comment">/**</span> 00598 <span class="comment"> * Setup socket timeout for the specified socket</span> 00599 <span class="comment"> * @param sock The socket to set up.</span> 00600 <span class="comment"> * @param t Value for the timeout.</span> 00601 <span class="comment"> * <PRE></span> 00602 <span class="comment"> * t > 0 -- read and write calls return APR_TIMEUP if specified time</span> 00603 <span class="comment"> * elapsess with no data read or written</span> 00604 <span class="comment"> * t == 0 -- read and write calls never block</span> 00605 <span class="comment"> * t < 0 -- read and write calls block</span> 00606 <span class="comment"> * </PRE></span> 00607 <span class="comment"> */</span> 00608 APR_DECLARE(apr_status_t) apr_socket_timeout_set(apr_socket_t *sock, 00609 apr_interval_time_t t); 00610 <span class="comment"></span> 00611 <span class="comment">/**</span> 00612 <span class="comment"> * Query socket options for the specified socket</span> 00613 <span class="comment"> * @param sock The socket to query</span> 00614 <span class="comment"> * @param opt The option we would like to query. One of:</span> 00615 <span class="comment"> * <PRE></span> 00616 <span class="comment"> * APR_SO_DEBUG -- turn on debugging information </span> 00617 <span class="comment"> * APR_SO_KEEPALIVE -- keep connections active</span> 00618 <span class="comment"> * APR_SO_LINGER -- lingers on close if data is present</span> 00619 <span class="comment"> * APR_SO_NONBLOCK -- Turns blocking on/off for socket</span> 00620 <span class="comment"> * APR_SO_REUSEADDR -- The rules used in validating addresses</span> 00621 <span class="comment"> * supplied to bind should allow reuse</span> 00622 <span class="comment"> * of local addresses.</span> 00623 <span class="comment"> * APR_SO_SNDBUF -- Set the SendBufferSize</span> 00624 <span class="comment"> * APR_SO_RCVBUF -- Set the ReceiveBufferSize</span> 00625 <span class="comment"> * APR_SO_DISCONNECTED -- Query the disconnected state of the socket.</span> 00626 <span class="comment"> * (Currently only used on Windows)</span> 00627 <span class="comment"> * </PRE></span> 00628 <span class="comment"> * @param on Socket option returned on the call.</span> 00629 <span class="comment"> */</span> 00630 APR_DECLARE(apr_status_t) apr_socket_opt_get(apr_socket_t *sock, 00631 apr_int32_t opt, apr_int32_t *on); 00632 <span class="comment"></span> 00633 <span class="comment">/**</span> 00634 <span class="comment"> * Query socket timeout for the specified socket</span> 00635 <span class="comment"> * @param sock The socket to query</span> 00636 <span class="comment"> * @param t Socket timeout returned from the query.</span> 00637 <span class="comment"> */</span> 00638 APR_DECLARE(apr_status_t) apr_socket_timeout_get(apr_socket_t *sock, 00639 apr_interval_time_t *t); 00640 <span class="comment"></span> 00641 <span class="comment">/**</span> 00642 <span class="comment"> * Query the specified socket if at the OOB/Urgent data mark</span> 00643 <span class="comment"> * @param sock The socket to query</span> 00644 <span class="comment"> * @param atmark Is set to true if socket is at the OOB/urgent mark,</span> 00645 <span class="comment"> * otherwise is set to false.</span> 00646 <span class="comment"> */</span> 00647 APR_DECLARE(apr_status_t) apr_socket_atmark(apr_socket_t *sock, 00648 <span class="keywordtype">int</span> *atmark); 00649 <span class="comment"></span> 00650 <span class="comment">/**</span> 00651 <span class="comment"> * Return an apr_sockaddr_t from an apr_socket_t</span> 00652 <span class="comment"> * @param sa The returned apr_sockaddr_t.</span> 00653 <span class="comment"> * @param which Which interface do we want the apr_sockaddr_t for?</span> 00654 <span class="comment"> * @param sock The socket to use</span> 00655 <span class="comment"> */</span> 00656 APR_DECLARE(apr_status_t) apr_socket_addr_get(apr_sockaddr_t **sa, 00657 apr_interface_e which, 00658 apr_socket_t *sock); 00659 <span class="comment"></span> 00660 <span class="comment">/**</span> 00661 <span class="comment"> * Return the IP address (in numeric address string format) in</span> 00662 <span class="comment"> * an APR socket address. APR will allocate storage for the IP address </span> 00663 <span class="comment"> * string from the pool of the apr_sockaddr_t.</span> 00664 <span class="comment"> * @param addr The IP address.</span> 00665 <span class="comment"> * @param sockaddr The socket address to reference.</span> 00666 <span class="comment"> */</span> 00667 APR_DECLARE(apr_status_t) apr_sockaddr_ip_get(<span class="keywordtype">char</span> **addr, 00668 apr_sockaddr_t *sockaddr); 00669 <span class="comment"></span> 00670 <span class="comment">/**</span> 00671 <span class="comment"> * See if the IP addresses in two APR socket addresses are</span> 00672 <span class="comment"> * equivalent. Appropriate logic is present for comparing</span> 00673 <span class="comment"> * IPv4-mapped IPv6 addresses with IPv4 addresses.</span> 00674 <span class="comment"> *</span> 00675 <span class="comment"> * @param addr1 One of the APR socket addresses.</span> 00676 <span class="comment"> * @param addr2 The other APR socket address.</span> 00677 <span class="comment"> * @remark The return value will be non-zero if the addresses</span> 00678 <span class="comment"> * are equivalent.</span> 00679 <span class="comment"> */</span> 00680 APR_DECLARE(<span class="keywordtype">int</span>) apr_sockaddr_equal(const apr_sockaddr_t *addr1, 00681 const apr_sockaddr_t *addr2); 00682 <span class="comment"></span> 00683 <span class="comment">/**</span> 00684 <span class="comment">* Return the type of the socket.</span> 00685 <span class="comment">* @param sock The socket to query.</span> 00686 <span class="comment">* @param type The returned type (e.g., SOCK_STREAM).</span> 00687 <span class="comment">*/</span> 00688 APR_DECLARE(apr_status_t) apr_socket_type_get(apr_socket_t *sock, 00689 <span class="keywordtype">int</span> *type); 00690 <span class="comment"></span> 00691 <span class="comment">/**</span> 00692 <span class="comment"> * Given an apr_sockaddr_t and a service name, set the port for the service</span> 00693 <span class="comment"> * @param sockaddr The apr_sockaddr_t that will have its port set</span> 00694 <span class="comment"> * @param servname The name of the service you wish to use</span> 00695 <span class="comment"> */</span> 00696 APR_DECLARE(apr_status_t) apr_getservbyname(apr_sockaddr_t *sockaddr, 00697 const <span class="keywordtype">char</span> *servname);<span class="comment"></span> 00698 <span class="comment">/**</span> 00699 <span class="comment"> * Build an ip-subnet representation from an IP address and optional netmask or</span> 00700 <span class="comment"> * number-of-bits.</span> 00701 <span class="comment"> * @param ipsub The new ip-subnet representation</span> 00702 <span class="comment"> * @param ipstr The input IP address string</span> 00703 <span class="comment"> * @param mask_or_numbits The input netmask or number-of-bits string, or NULL</span> 00704 <span class="comment"> * @param p The pool to allocate from</span> 00705 <span class="comment"> */</span> 00706 APR_DECLARE(apr_status_t) apr_ipsubnet_create(apr_ipsubnet_t **ipsub, 00707 const <span class="keywordtype">char</span> *ipstr, 00708 const <span class="keywordtype">char</span> *mask_or_numbits, 00709 apr_pool_t *p); 00710 <span class="comment"></span> 00711 <span class="comment">/**</span> 00712 <span class="comment"> * Test the IP address in an apr_sockaddr_t against a pre-built ip-subnet</span> 00713 <span class="comment"> * representation.</span> 00714 <span class="comment"> * @param ipsub The ip-subnet representation</span> 00715 <span class="comment"> * @param sa The socket address to test</span> 00716 <span class="comment"> * @return non-zero if the socket address is within the subnet, 0 otherwise</span> 00717 <span class="comment"> */</span> 00718 APR_DECLARE(<span class="keywordtype">int</span>) apr_ipsubnet_test(apr_ipsubnet_t *ipsub, apr_sockaddr_t *sa); 00719 00720 #if APR_HAS_SO_ACCEPTFILTER || defined(DOXYGEN)<span class="comment"></span> 00721 <span class="comment">/**</span> 00722 <span class="comment"> * Set an OS level accept filter.</span> 00723 <span class="comment"> * @param sock The socket to put the accept filter on.</span> 00724 <span class="comment"> * @param name The accept filter</span> 00725 <span class="comment"> * @param args Any extra args to the accept filter. Passing NULL here removes</span> 00726 <span class="comment"> * the accept filter. </span> 00727 <span class="comment"> */</span> 00728 apr_status_t apr_socket_accept_filter(apr_socket_t *sock, <span class="keywordtype">char</span> *name, 00729 <span class="keywordtype">char</span> *args); 00730 #endif 00731 <span class="comment"></span> 00732 <span class="comment">/**</span> 00733 <span class="comment"> * Return the protocol of the socket.</span> 00734 <span class="comment"> * @param sock The socket to query.</span> 00735 <span class="comment"> * @param protocol The returned protocol (e.g., APR_PROTO_TCP).</span> 00736 <span class="comment"> */</span> 00737 APR_DECLARE(apr_status_t) apr_socket_protocol_get(apr_socket_t *sock, 00738 <span class="keywordtype">int</span> *protocol); 00739 <span class="comment"></span> 00740 <span class="comment">/**</span> 00741 <span class="comment"> * Set a socket to be inherited by child processes.</span> 00742 <span class="comment"> */</span> 00743 APR_DECLARE_INHERIT_SET(socket); 00744 <span class="comment"></span> 00745 <span class="comment">/**</span> 00746 <span class="comment"> * Unset a socket from being inherited by child processes.</span> 00747 <span class="comment"> */</span> 00748 APR_DECLARE_INHERIT_UNSET(socket); 00749 <span class="comment"></span> 00750 <span class="comment">/**</span> 00751 <span class="comment"> * @defgroup apr_mcast IP Multicast</span> 00752 <span class="comment"> * @{</span> 00753 <span class="comment"> */</span> 00754 <span class="comment"></span> 00755 <span class="comment">/**</span> 00756 <span class="comment"> * Join a Multicast Group</span> 00757 <span class="comment"> * @param sock The socket to join a multicast group</span> 00758 <span class="comment"> * @param join The address of the multicast group to join</span> 00759 <span class="comment"> * @param iface Address of the interface to use. If NULL is passed, the </span> 00760 <span class="comment"> * default multicast interface will be used. (OS Dependent)</span> 00761 <span class="comment"> * @param source Source Address to accept transmissions from (non-NULL </span> 00762 <span class="comment"> * implies Source-Specific Multicast)</span> 00763 <span class="comment"> */</span> 00764 APR_DECLARE(apr_status_t) apr_mcast_join(apr_socket_t *sock, 00765 apr_sockaddr_t *join, 00766 apr_sockaddr_t *iface, 00767 apr_sockaddr_t *source); 00768 <span class="comment"></span> 00769 <span class="comment">/**</span> 00770 <span class="comment"> * Leave a Multicast Group. All arguments must be the same as</span> 00771 <span class="comment"> * apr_mcast_join.</span> 00772 <span class="comment"> * @param sock The socket to leave a multicast group</span> 00773 <span class="comment"> * @param addr The address of the multicast group to leave</span> 00774 <span class="comment"> * @param iface Address of the interface to use. If NULL is passed, the </span> 00775 <span class="comment"> * default multicast interface will be used. (OS Dependent)</span> 00776 <span class="comment"> * @param source Source Address to accept transmissions from (non-NULL </span> 00777 <span class="comment"> * implies Source-Specific Multicast)</span> 00778 <span class="comment"> */</span> 00779 APR_DECLARE(apr_status_t) apr_mcast_leave(apr_socket_t *sock, 00780 apr_sockaddr_t *addr, 00781 apr_sockaddr_t *iface, 00782 apr_sockaddr_t *source); 00783 <span class="comment"></span> 00784 <span class="comment">/**</span> 00785 <span class="comment"> * Set the Multicast Time to Live (ttl) for a multicast transmission.</span> 00786 <span class="comment"> * @param sock The socket to set the multicast ttl</span> 00787 <span class="comment"> * @param ttl Time to live to Assign. 0-255, default=1</span> 00788 <span class="comment"> * @remark If the TTL is 0, packets will only be seen by sockets on </span> 00789 <span class="comment"> * the local machine, and only when multicast loopback is enabled.</span> 00790 <span class="comment"> */</span> 00791 APR_DECLARE(apr_status_t) apr_mcast_hops(apr_socket_t *sock, 00792 apr_byte_t ttl); 00793 <span class="comment"></span> 00794 <span class="comment">/**</span> 00795 <span class="comment"> * Toggle IP Multicast Loopback</span> 00796 <span class="comment"> * @param sock The socket to set multicast loopback</span> 00797 <span class="comment"> * @param opt 0=disable, 1=enable</span> 00798 <span class="comment"> */</span> 00799 APR_DECLARE(apr_status_t) apr_mcast_loopback(apr_socket_t *sock, 00800 apr_byte_t opt); 00801 00802 <span class="comment"></span> 00803 <span class="comment">/**</span> 00804 <span class="comment"> * Set the Interface to be used for outgoing Multicast Transmissions.</span> 00805 <span class="comment"> * @param sock The socket to set the multicast interface on</span> 00806 <span class="comment"> * @param iface Address of the interface to use for Multicast</span> 00807 <span class="comment"> */</span> 00808 APR_DECLARE(apr_status_t) apr_mcast_interface(apr_socket_t *sock, 00809 apr_sockaddr_t *iface); 00810 <span class="comment"></span> 00811 <span class="comment">/** @} */</span> 00812 <span class="comment"></span> 00813 <span class="comment">/** @} */</span> 00814 00815 #ifdef __cplusplus 00816 } 00817 #endif 00818 00819 #endif <span class="comment">/* ! APR_NETWORK_IO_H */</span> 00820 </pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Mar 20 19:52:26 2005 for Apache Portable Runtime by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.3.9.1 </small></address> </body> </html>