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

📄 aprsocketconnector.html

📁 MINA+API 关于MINA的API
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<a name="223" href="#223">223</a>                 <strong class="jxr_keyword">if</strong> (rv != Status.APR_SUCCESS) {<a name="224" href="#224">224</a>                     throwException(rv);<a name="225" href="#225">225</a>                 }<a name="226" href="#226">226</a>             }<a name="227" href="#227">227</a>         }<a name="228" href="#228">228</a>     }<a name="229" href="#229">229</a> <a name="230" href="#230">230</a>     @Override<a name="231" href="#231">231</a>     <strong class="jxr_keyword">protected</strong> <a href="../../../../../../org/apache/mina/transport/socket/apr/AprSession.html">AprSession</a> newSession(IoProcessor&lt;AprSession&gt; processor,<a name="232" href="#232">232</a>             Long handle) <strong class="jxr_keyword">throws</strong> Exception {<a name="233" href="#233">233</a>         <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/mina/transport/socket/apr/AprSocketSession.html">AprSocketSession</a>(<strong class="jxr_keyword">this</strong>, processor, handle);<a name="234" href="#234">234</a>     }<a name="235" href="#235">235</a> <a name="236" href="#236">236</a>     @Override<a name="237" href="#237">237</a>     <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">void</strong> register(Long handle, <a href="../../../../../../org/apache/mina/common/AbstractPollingIoConnector.html">ConnectionRequest</a> request)<a name="238" href="#238">238</a>             <strong class="jxr_keyword">throws</strong> Exception {<a name="239" href="#239">239</a>         <strong class="jxr_keyword">int</strong> rv = Poll.add(pollset, handle, Poll.APR_POLLOUT);<a name="240" href="#240">240</a>         <strong class="jxr_keyword">if</strong> (rv != Status.APR_SUCCESS) {<a name="241" href="#241">241</a>             throwException(rv);<a name="242" href="#242">242</a>         }<a name="243" href="#243">243</a>         <a name="244" href="#244">244</a>         requests.put(handle, request);<a name="245" href="#245">245</a>     }<a name="246" href="#246">246</a> <a name="247" href="#247">247</a>     @Override<a name="248" href="#248">248</a>     <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">boolean</strong> select(<strong class="jxr_keyword">int</strong> timeout) <strong class="jxr_keyword">throws</strong> Exception {<a name="249" href="#249">249</a>         <strong class="jxr_keyword">int</strong> rv = Poll.poll(pollset, timeout * 1000, polledSockets, false);<a name="250" href="#250">250</a>         <strong class="jxr_keyword">if</strong> (rv &lt;= 0) {<a name="251" href="#251">251</a>             <strong class="jxr_keyword">if</strong> (rv != -120001) {<a name="252" href="#252">252</a>                 throwException(rv);<a name="253" href="#253">253</a>             }<a name="254" href="#254">254</a>             <a name="255" href="#255">255</a>             rv = Poll.maintain(pollset, polledSockets, <strong class="jxr_keyword">true</strong>);<a name="256" href="#256">256</a>             <strong class="jxr_keyword">if</strong> (rv &gt; 0) {<a name="257" href="#257">257</a>                 <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 0; i &lt; rv; i ++) {<a name="258" href="#258">258</a>                     Poll.add(pollset, polledSockets[i], Poll.APR_POLLOUT);<a name="259" href="#259">259</a>                 }<a name="260" href="#260">260</a>             } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (rv &lt; 0) {<a name="261" href="#261">261</a>                 throwException(rv);<a name="262" href="#262">262</a>             }<a name="263" href="#263">263</a>             <a name="264" href="#264">264</a>             <strong class="jxr_keyword">return</strong> false;<a name="265" href="#265">265</a>         } <strong class="jxr_keyword">else</strong> {<a name="266" href="#266">266</a>             rv &lt;&lt;= 1;<a name="267" href="#267">267</a>             <strong class="jxr_keyword">if</strong> (!polledHandles.isEmpty()) {<a name="268" href="#268">268</a>                 polledHandles.clear();<a name="269" href="#269">269</a>             }<a name="270" href="#270">270</a> <a name="271" href="#271">271</a>             <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 0; i &lt; rv; i ++) {<a name="272" href="#272">272</a>                 <strong class="jxr_keyword">long</strong> flag = polledSockets[i];<a name="273" href="#273">273</a>                 <strong class="jxr_keyword">long</strong> socket = polledSockets[++i];<a name="274" href="#274">274</a>                 <strong class="jxr_keyword">if</strong> (socket == wakeupSocket) {<a name="275" href="#275">275</a>                     <strong class="jxr_keyword">synchronized</strong> (wakeupLock) {<a name="276" href="#276">276</a>                         Poll.remove(pollset, wakeupSocket);<a name="277" href="#277">277</a>                         toBeWakenUp = false;<a name="278" href="#278">278</a>                     }<a name="279" href="#279">279</a>                     <strong class="jxr_keyword">continue</strong>;<a name="280" href="#280">280</a>                 }<a name="281" href="#281">281</a>                 polledHandles.add(socket);<a name="282" href="#282">282</a>                 <strong class="jxr_keyword">if</strong> ((flag &amp; Poll.APR_POLLOUT) == 0) {<a name="283" href="#283">283</a>                     failedHandles.add(socket);<a name="284" href="#284">284</a>                 }<a name="285" href="#285">285</a>             }<a name="286" href="#286">286</a>             <strong class="jxr_keyword">return</strong> !polledHandles.isEmpty();<a name="287" href="#287">287</a>         }<a name="288" href="#288">288</a>     }<a name="289" href="#289">289</a> <a name="290" href="#290">290</a>     @Override<a name="291" href="#291">291</a>     <strong class="jxr_keyword">protected</strong> Iterator&lt;Long&gt; selectedHandles() {<a name="292" href="#292">292</a>         <strong class="jxr_keyword">return</strong> polledHandles.iterator();<a name="293" href="#293">293</a>     }<a name="294" href="#294">294</a> <a name="295" href="#295">295</a>     @Override<a name="296" href="#296">296</a>     <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">void</strong> wakeup() {<a name="297" href="#297">297</a>         <strong class="jxr_keyword">if</strong> (toBeWakenUp) {<a name="298" href="#298">298</a>             <strong class="jxr_keyword">return</strong>;<a name="299" href="#299">299</a>         }<a name="300" href="#300">300</a>         <a name="301" href="#301">301</a>         <em class="jxr_comment">// Add a dummy socket to the pollset.</em><a name="302" href="#302">302</a>         <strong class="jxr_keyword">synchronized</strong> (wakeupLock) {<a name="303" href="#303">303</a>             toBeWakenUp = <strong class="jxr_keyword">true</strong>;<a name="304" href="#304">304</a>             Poll.add(pollset, wakeupSocket, Poll.APR_POLLOUT);<a name="305" href="#305">305</a>         }<a name="306" href="#306">306</a>     }<a name="307" href="#307">307</a> <a name="308" href="#308">308</a>     <strong class="jxr_keyword">public</strong> <a href="../../../../../../org/apache/mina/common/TransportMetadata.html">TransportMetadata</a> getTransportMetadata() {<a name="309" href="#309">309</a>         <strong class="jxr_keyword">return</strong> AprSocketSession.METADATA;<a name="310" href="#310">310</a>     }<a name="311" href="#311">311</a>     <a name="312" href="#312">312</a>     @Override<a name="313" href="#313">313</a>     <strong class="jxr_keyword">public</strong> <a href="../../../../../../org/apache/mina/transport/socket/SocketSessionConfig.html">SocketSessionConfig</a> getSessionConfig() {<a name="314" href="#314">314</a>         <strong class="jxr_keyword">return</strong> (SocketSessionConfig) <strong class="jxr_keyword">super</strong>.getSessionConfig();<a name="315" href="#315">315</a>     }<a name="316" href="#316">316</a>     <a name="317" href="#317">317</a>     @Override<a name="318" href="#318">318</a>     <strong class="jxr_keyword">public</strong> InetSocketAddress getDefaultRemoteAddress() {<a name="319" href="#319">319</a>         <strong class="jxr_keyword">return</strong> (InetSocketAddress) <strong class="jxr_keyword">super</strong>.getDefaultRemoteAddress();<a name="320" href="#320">320</a>     }<a name="321" href="#321">321</a>     <a name="322" href="#322">322</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setDefaultRemoteAddress(InetSocketAddress defaultRemoteAddress) {<a name="323" href="#323">323</a>         <strong class="jxr_keyword">super</strong>.setDefaultRemoteAddress(defaultRemoteAddress);<a name="324" href="#324">324</a>     }<a name="325" href="#325">325</a> <a name="326" href="#326">326</a>     <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> throwException(<strong class="jxr_keyword">int</strong> code) <strong class="jxr_keyword">throws</strong> IOException {<a name="327" href="#327">327</a>         <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> IOException(<a name="328" href="#328">328</a>                 org.apache.tomcat.jni.Error.strerror(-code) +<a name="329" href="#329">329</a>                 <span class="jxr_string">" (code: "</span> + code + <span class="jxr_string">")"</span>);<a name="330" href="#330">330</a>     }<a name="331" href="#331">331</a> }</pre><hr/><div id="footer">This page was automatically generated by <a href="http://maven.apache.org/">Maven</a></div></body></html>

⌨️ 快捷键说明

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