⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 apr__network__io_8h-source.html

📁 apr函数库使用手册
💻 HTML
📖 第 1 页 / 共 5 页
字号:
00149 <span class="preprocessor"></span><span class="preprocessor">#if APR_HAVE_IPV6</span>
00150 <span class="preprocessor"></span><span class="comment">/** @def APR_INET6</span>
00151 <span class="comment">* IPv6 Address Family. Not all platforms may have this defined.</span>
00152 <span class="comment">*/</span>
00153 
00154 <span class="preprocessor">#define APR_INET6    AF_INET6</span>
00155 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
00156 <span class="preprocessor"></span><span class="comment"></span>
00157 <span class="comment">/**</span>
00158 <span class="comment"> * @defgroup IP_Proto IP Protocol Definitions for use when creating sockets</span>
00159 <span class="comment"> * @{</span>
00160 <span class="comment"> */</span>
<a name="l00161"></a><a class="code" href="group___i_p___proto.html#ga0">00161</a> <span class="preprocessor">#define APR_PROTO_TCP       6   </span><span class="comment">/**&lt; TCP  */</span>
<a name="l00162"></a><a class="code" href="group___i_p___proto.html#ga1">00162</a> <span class="preprocessor">#define APR_PROTO_UDP      17   </span><span class="comment">/**&lt; UDP  */</span>
<a name="l00163"></a><a class="code" href="group___i_p___proto.html#ga2">00163</a> <span class="preprocessor">#define APR_PROTO_SCTP    132   </span><span class="comment">/**&lt; SCTP */</span>
00164 <span class="comment">/** @} */</span>
00165 <span class="comment"></span>
00166 <span class="comment">/**</span>
00167 <span class="comment"> * Enum to tell us if we're interested in remote or local socket</span>
00168 <span class="comment"> */</span>
<a name="l00169"></a><a class="code" href="group__apr__network__io.html#ga50">00169</a> <span class="keyword">typedef</span> <span class="keyword">enum</span> {
00170     APR_LOCAL,
00171     APR_REMOTE
00172 } <a class="code" href="group__apr__network__io.html#ga50">apr_interface_e</a>;
00173 <span class="comment"></span>
00174 <span class="comment">/**</span>
00175 <span class="comment"> * The specific declaration of inet_addr's ... some platforms fall back</span>
00176 <span class="comment"> * inet_network (this is not good, but necessary)</span>
00177 <span class="comment"> */</span>
00178 
00179 <span class="preprocessor">#if APR_HAVE_INET_ADDR</span>
00180 <span class="preprocessor"></span><span class="preprocessor">#define apr_inet_addr    inet_addr</span>
00181 <span class="preprocessor"></span><span class="preprocessor">#elif APR_HAVE_INET_NETWORK        </span><span class="comment">/* only DGUX, as far as I know */</span>
00182 <span class="comment">/**</span>
00183 <span class="comment"> * @warning</span>
00184 <span class="comment"> * not generally safe... inet_network() and inet_addr() perform</span>
00185 <span class="comment"> * different functions */</span>
00186 <span class="preprocessor">#define apr_inet_addr    inet_network</span>
00187 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
00188 <span class="preprocessor"></span><span class="comment"></span>
00189 <span class="comment">/** A structure to represent sockets */</span>
<a name="l00190"></a><a class="code" href="group__apr__network__io.html#ga0">00190</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>
00191 <span class="comment">/**</span>
00192 <span class="comment"> * A structure to encapsulate headers and trailers for apr_socket_sendfile</span>
00193 <span class="comment"> */</span>
<a name="l00194"></a><a class="code" href="group__apr__network__io.html#ga1">00194</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>
00195 <span class="comment">/** A structure to represent in_addr */</span>
<a name="l00196"></a><a class="code" href="group__apr__network__io.html#ga2">00196</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structin__addr.html">in_addr</a>          <a class="code" href="group__apr__network__io.html#ga2">apr_in_addr_t</a>;<span class="comment"></span>
00197 <span class="comment">/** A structure to represent an IP subnet */</span>
<a name="l00198"></a><a class="code" href="group__apr__network__io.html#ga3">00198</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>;
00199 <span class="comment"></span>
00200 <span class="comment">/** @remark use apr_uint16_t just in case some system has a short that isn't 16 bits... */</span>
<a name="l00201"></a><a class="code" href="group__apr__network__io.html#ga4">00201</a> <span class="keyword">typedef</span> apr_uint16_t            <a class="code" href="group__apr__network__io.html#ga4">apr_port_t</a>;
00202 <span class="comment"></span>
00203 <span class="comment">/** @remark It's defined here as I think it should all be platform safe...</span>
00204 <span class="comment"> * @see apr_sockaddr_t</span>
00205 <span class="comment"> */</span>
<a name="l00206"></a><a class="code" href="group__apr__network__io.html#ga5">00206</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>
00207 <span class="comment">/**</span>
00208 <span class="comment"> * APRs socket address type, used to ensure protocol independence</span>
00209 <span class="comment"> */</span>
<a name="l00210"></a><a class="code" href="structapr__sockaddr__t.html">00210</a> <span class="keyword">struct </span><a class="code" href="group__apr__network__io.html#ga5">apr_sockaddr_t</a> {<span class="comment"></span>
00211 <span class="comment">    /** The pool to use... */</span>
<a name="l00212"></a><a class="code" href="structapr__sockaddr__t.html#o0">00212</a>     <a class="code" href="group__apr__pools.html#ga0">apr_pool_t</a> *<a class="code" href="structapr__sockaddr__t.html#o0">pool</a>;<span class="comment"></span>
00213 <span class="comment">    /** The hostname */</span>
<a name="l00214"></a><a class="code" href="structapr__sockaddr__t.html#o1">00214</a>     <span class="keywordtype">char</span> *<a class="code" href="structapr__sockaddr__t.html#o1">hostname</a>;<span class="comment"></span>
00215 <span class="comment">    /** Either a string of the port number or the service name for the port */</span>
<a name="l00216"></a><a class="code" href="structapr__sockaddr__t.html#o2">00216</a>     <span class="keywordtype">char</span> *<a class="code" href="structapr__sockaddr__t.html#o2">servname</a>;<span class="comment"></span>
00217 <span class="comment">    /** The numeric port */</span>
<a name="l00218"></a><a class="code" href="structapr__sockaddr__t.html#o3">00218</a>     <a class="code" href="group__apr__network__io.html#ga4">apr_port_t</a> <a class="code" href="structapr__sockaddr__t.html#o3">port</a>;<span class="comment"></span>
00219 <span class="comment">    /** The family */</span>
<a name="l00220"></a><a class="code" href="structapr__sockaddr__t.html#o4">00220</a>     apr_int32_t <a class="code" href="structapr__sockaddr__t.html#o4">family</a>;<span class="comment"></span>
00221 <span class="comment">    /** How big is the sockaddr we're using? */</span>
<a name="l00222"></a><a class="code" href="structapr__sockaddr__t.html#o5">00222</a>     apr_socklen_t <a class="code" href="structapr__sockaddr__t.html#o5">salen</a>;<span class="comment"></span>
00223 <span class="comment">    /** How big is the ip address structure we're using? */</span>
<a name="l00224"></a><a class="code" href="structapr__sockaddr__t.html#o6">00224</a>     <span class="keywordtype">int</span> <a class="code" href="structapr__sockaddr__t.html#o6">ipaddr_len</a>;<span class="comment"></span>
00225 <span class="comment">    /** How big should the address buffer be?  16 for v4 or 46 for v6</span>
00226 <span class="comment">     *  used in inet_ntop... */</span>
<a name="l00227"></a><a class="code" href="structapr__sockaddr__t.html#o7">00227</a>     <span class="keywordtype">int</span> <a class="code" href="structapr__sockaddr__t.html#o7">addr_str_len</a>;<span class="comment"></span>
00228 <span class="comment">    /** This points to the IP address structure within the appropriate</span>
00229 <span class="comment">     *  sockaddr structure.  */</span>
<a name="l00230"></a><a class="code" href="structapr__sockaddr__t.html#o8">00230</a>     <span class="keywordtype">void</span> *<a class="code" href="structapr__sockaddr__t.html#o8">ipaddr_ptr</a>;<span class="comment"></span>
00231 <span class="comment">    /** If multiple addresses were found by apr_sockaddr_info_get(), this </span>
00232 <span class="comment">     *  points to a representation of the next address. */</span>
<a name="l00233"></a><a class="code" href="structapr__sockaddr__t.html#o9">00233</a>     <a class="code" href="group__apr__network__io.html#ga5">apr_sockaddr_t</a> *<a class="code" href="structapr__sockaddr__t.html#o9">next</a>;<span class="comment"></span>
00234 <span class="comment">    /** Union of either IPv4 or IPv6 sockaddr. */</span>
00235     <span class="keyword">union </span>{<span class="comment"></span>
00236 <span class="comment">        /** IPv4 sockaddr structure */</span>
<a name="l00237"></a><a class="code" href="structapr__sockaddr__t.html#o10">00237</a>         <span class="keyword">struct </span>sockaddr_in sin;
00238 <span class="preprocessor">#if APR_HAVE_IPV6</span>
00239 <span class="preprocessor"></span><span class="comment">        /** IPv6 sockaddr structure */</span>
00240         <span class="keyword">struct </span>sockaddr_in6 sin6;
00241 <span class="preprocessor">#endif</span>
00242 <span class="preprocessor"></span><span class="preprocessor">#if APR_HAVE_SA_STORAGE</span>
00243 <span class="preprocessor"></span><span class="comment">        /** Placeholder to ensure that the size of this union is not</span>
00244 <span class="comment">         * dependent on whether APR_HAVE_IPV6 is defined. */</span>
00245         <span class="keyword">struct </span>sockaddr_storage sas;
00246 <span class="preprocessor">#endif</span>
00247 <span class="preprocessor"></span>    } sa;
00248 };
00249 
00250 <span class="preprocessor">#if APR_HAS_SENDFILE</span>
00251 <span class="preprocessor"></span><span class="comment">/** </span>
00252 <span class="comment"> * Support reusing the socket on platforms which support it (from disconnect,</span>
00253 <span class="comment"> * specifically Win32.</span>
00254 <span class="comment"> * @remark Optional flag passed into apr_socket_sendfile() </span>
00255 <span class="comment"> */</span>
00256 <span class="preprocessor">#define APR_SENDFILE_DISCONNECT_SOCKET      1</span>
00257 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
00258 <span class="preprocessor"></span><span class="comment"></span>
00259 <span class="comment">/** A structure to encapsulate headers and trailers for apr_socket_sendfile */</span>
<a name="l00260"></a><a class="code" href="structapr__hdtr__t.html">00260</a> <span class="keyword">struct </span><a class="code" href="group__apr__network__io.html#ga1">apr_hdtr_t</a> {<span class="comment"></span>
00261 <span class="comment">    /** An iovec to store the headers sent before the file. */</span>
<a name="l00262"></a><a class="code" href="structapr__hdtr__t.html#o0">00262</a>     <span class="keyword">struct </span>iovec* <a class="code" href="structapr__hdtr__t.html#o0">headers</a>;<span class="comment"></span>
00263 <span class="comment">    /** number of headers in the iovec */</span>
<a name="l00264"></a><a class="code" href="structapr__hdtr__t.html#o1">00264</a>     <span class="keywordtype">int</span> <a class="code" href="structapr__hdtr__t.html#o1">numheaders</a>;<span class="comment"></span>
00265 <span class="comment">    /** An iovec to store the trailers sent after the file. */</span>
<a name="l00266"></a><a class="code" href="structapr__hdtr__t.html#o2">00266</a>     <span class="keyword">struct </span>iovec* <a class="code" href="structapr__hdtr__t.html#o2">trailers</a>;<span class="comment"></span>
00267 <span class="comment">    /** number of trailers in the iovec */</span>
<a name="l00268"></a><a class="code" href="structapr__hdtr__t.html#o3">00268</a>     <span class="keywordtype">int</span> <a class="code" href="structapr__hdtr__t.html#o3">numtrailers</a>;
00269 };
00270 
00271 <span class="comment">/* function definitions */</span>
00272 <span class="comment"></span>
00273 <span class="comment">/**</span>
00274 <span class="comment"> * Create a socket.</span>
00275 <span class="comment"> * @param new_sock The new socket that has been set up.</span>
00276 <span class="comment"> * @param family The address family of the socket (e.g., APR_INET).</span>
00277 <span class="comment"> * @param type The type of the socket (e.g., SOCK_STREAM).</span>
00278 <span class="comment"> * @param protocol The protocol of the socket (e.g., APR_PROTO_TCP).</span>
00279 <span class="comment"> * @param cont The pool to use</span>
00280 <span class="comment"> */</span>
00281 APR_DECLARE(apr_status_t) apr_socket_create(apr_socket_t **new_sock, 
00282                                             <span class="keywordtype">int</span> family, <span class="keywordtype">int</span> type,
00283                                             <span class="keywordtype">int</span> protocol,
00284                                             apr_pool_t *cont);
00285 <span class="comment"></span>
00286 <span class="comment">/**</span>
00287 <span class="comment"> * Shutdown either reading, writing, or both sides of a socket.</span>
00288 <span class="comment"> * @param thesocket The socket to close </span>
00289 <span class="comment"> * @param how How to shutdown the socket.  One of:</span>
00290 <span class="comment"> * &lt;PRE&gt;</span>
00291 <span class="comment"> *            APR_SHUTDOWN_READ         no longer allow read requests</span>
00292 <span class="comment"> *            APR_SHUTDOWN_WRITE        no longer allow write requests</span>
00293 <span class="comment"> *            APR_SHUTDOWN_READWRITE    no longer allow read or write requests </span>
00294 <span class="comment"> * &lt;/PRE&gt;</span>
00295 <span class="comment"> * @see apr_shutdown_how_e</span>
00296 <span class="comment"> * @remark This does not actually close the socket descriptor, it just</span>
00297 <span class="comment"> *      controls which calls are still valid on the socket.</span>
00298 <span class="comment"> */</span>
00299 APR_DECLARE(apr_status_t) apr_socket_shutdown(apr_socket_t *thesocket,
00300                                               apr_shutdown_how_e how);
00301 <span class="comment"></span>
00302 <span class="comment">/**</span>
00303 <span class="comment"> * Close a socket.</span>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -