📄 class_c_chat_inet.html
字号:
<tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">void CChatInet::StartL </td> <td class="md" valign="top">( </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>StartL Start server. <p>Definition at line <a class="el" href="_chat_inet_8cpp-source.html#l00468">468</a> of file <a class="el" href="_chat_inet_8cpp-source.html">ChatInet.cpp</a>.<p>References <a class="el" href="_chat_inet_8h-source.html#l00200">iAcceptedSocket</a>, <a class="el" href="_chat_inet_8h-source.html#l00230">iActiveSocket</a>, <a class="el" href="_chat_inet_8h-source.html#l00188">iAddress</a>, <a class="el" href="_chat_inet_8h-source.html#l00164">iConnection</a>, <a class="el" href="_chat_inet_8h-source.html#l00194">iPort</a>, <a class="el" href="_chat_inet_8h-source.html#l00176">iSocket</a>, <a class="el" href="_chat_inet_8h-source.html#l00170">iSocketServer</a>, <a class="el" href="_chat_base_8cpp-source.html#l00120">CChatBase::SetServer()</a>, <a class="el" href="_chat_base_8cpp-source.html#l00130">CChatBase::SetState()</a>, and <a class="el" href="_chat_base_8cpp-source.html#l00140">CChatBase::State()</a>.<div class="fragment"><pre class="fragment"><a name="l00469"></a>00469 {<a name="l00470"></a>00470 <span class="keywordflow">if</span> ( <a class="code" href="class_c_chat_base.html#af77e92297a4bac4704e440284577ebe">State</a>() != EDisconnected )<a name="l00471"></a>00471 {<a name="l00472"></a>00472 User::Leave( KErrInUse );<a name="l00473"></a>00473 }<a name="l00474"></a>00474 <a name="l00475"></a>00475 User::LeaveIfError( <a class="code" href="class_c_chat_inet.html#f702971f167e073a81134fd2876d0298">iConnection</a>.Open( <a class="code" href="class_c_chat_inet.html#56bd53f21c6818eaa0d4a1ad2c7c5a84">iSocketServer</a>, KAfInet) );<a name="l00476"></a>00476 <a name="l00477"></a>00477 User::LeaveIfError( <a class="code" href="class_c_chat_inet.html#f702971f167e073a81134fd2876d0298">iConnection</a>.Start() );<a name="l00478"></a>00478 <a name="l00479"></a>00479 TInt result( 0 );<a name="l00480"></a>00480 <a name="l00481"></a>00481 result = <a class="code" href="class_c_chat_inet.html#4791a9b2a2447d2068a89acb05c8c25b">iSocket</a>.Open( <a class="code" href="class_c_chat_inet.html#56bd53f21c6818eaa0d4a1ad2c7c5a84">iSocketServer</a>, <a name="l00482"></a>00482 KAfInet, <a name="l00483"></a>00483 KSockStream, <a name="l00484"></a>00484 KProtocolInetTcp );<a name="l00485"></a>00485 <a name="l00486"></a>00486 <span class="keywordflow">if</span> ( result != KErrNone )<a name="l00487"></a>00487 {<a name="l00488"></a>00488 <a class="code" href="class_c_chat_inet.html#56bd53f21c6818eaa0d4a1ad2c7c5a84">iSocketServer</a>.Close();<a name="l00489"></a>00489 User::Leave( result ); <a name="l00490"></a>00490 }<a name="l00491"></a>00491 <a name="l00492"></a>00492 TInetAddr addr;<a name="l00493"></a>00493 <a class="code" href="class_c_chat_inet.html#5d2af0e4e421312918bddbe0e0861f28">iAddress</a>.SetPort( <a class="code" href="class_c_chat_inet.html#ca13b175f9849e6ff5ce23ea58682739">iPort</a> );<a name="l00494"></a>00494 <a class="code" href="class_c_chat_inet.html#5d2af0e4e421312918bddbe0e0861f28">iAddress</a>.SetFamily( KAfInet );<a name="l00495"></a>00495 <a name="l00496"></a>00496 <span class="comment">// bind</span><a name="l00497"></a>00497 User::LeaveIfError( <a class="code" href="class_c_chat_inet.html#4791a9b2a2447d2068a89acb05c8c25b">iSocket</a>.Bind( <a class="code" href="class_c_chat_inet.html#5d2af0e4e421312918bddbe0e0861f28">iAddress</a> ) );<a name="l00498"></a>00498 <a name="l00499"></a>00499 <span class="comment">// listen</span><a name="l00500"></a>00500 User::LeaveIfError( <a class="code" href="class_c_chat_inet.html#4791a9b2a2447d2068a89acb05c8c25b">iSocket</a>.Listen( KListeningQueSize ) );<a name="l00501"></a>00501 <a name="l00502"></a>00502 <span class="comment">// close old connection - if any</span><a name="l00503"></a>00503 <a class="code" href="class_c_chat_inet.html#43d47cb0a780f4af02110487231ac627">iAcceptedSocket</a>.Close();<a name="l00504"></a>00504 <a name="l00505"></a>00505 <span class="comment">// Open abstract socket</span><a name="l00506"></a>00506 User::LeaveIfError( <a class="code" href="class_c_chat_inet.html#43d47cb0a780f4af02110487231ac627">iAcceptedSocket</a>.Open( <a class="code" href="class_c_chat_inet.html#56bd53f21c6818eaa0d4a1ad2c7c5a84">iSocketServer</a> ) ); <a name="l00507"></a>00507 <a name="l00508"></a>00508 <a class="code" href="class_c_chat_inet.html#42435def2f80909f7700ad684c625f0f">iActiveSocket</a> = &<a class="code" href="class_c_chat_inet.html#43d47cb0a780f4af02110487231ac627">iAcceptedSocket</a>;<a name="l00509"></a>00509 <a name="l00510"></a>00510 <span class="comment">// Set the Active Object's State to Connecting indicated.</span><a name="l00511"></a>00511 <a class="code" href="class_c_chat_base.html#deacd9f98d0548748cf116698aea2be0">SetState</a>( EGettingConnection );<a name="l00512"></a>00512 <a name="l00513"></a>00513 <a class="code" href="class_c_chat_inet.html#4791a9b2a2447d2068a89acb05c8c25b">iSocket</a>.Accept( <a class="code" href="class_c_chat_inet.html#43d47cb0a780f4af02110487231ac627">iAcceptedSocket</a>, iStatus );<a name="l00514"></a>00514 <a name="l00515"></a>00515 <a class="code" href="class_c_chat_base.html#3632b5e9a01d31118bbf932b3cd23f34">SetServer</a>( ETrue );<a name="l00516"></a>00516 <a name="l00517"></a>00517 <span class="comment">// Set the Active Object Active again,</span><a name="l00518"></a>00518 SetActive();<a name="l00519"></a>00519 <a name="l00520"></a>00520 }</pre></div><p> </td> </tr></table><a class="anchor" name="345d0d754ebc6b15fd182f42d46a1310"></a><!-- doxytag: member="CChatInet::ConnectL" ref="345d0d754ebc6b15fd182f42d46a1310" args="(TUint32 aAddr)" --><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">void CChatInet::ConnectL </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">TUint32 </td> <td class="mdname1" valign="top" nowrap> <em>aAddr</em> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap><code> [private]</code></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>ConnectL Connect to server. <dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>aAddr</em> </td><td>address to connect to </td></tr> </table></dl><p>Definition at line <a class="el" href="_chat_inet_8cpp-source.html#l00404">404</a> of file <a class="el" href="_chat_inet_8cpp-source.html">ChatInet.cpp</a>.<p>References <a class="el" href="_chat_inet_8h-source.html#l00230">iActiveSocket</a>, <a class="el" href="_chat_inet_8h-source.html#l00188">iAddress</a>, <a class="el" href="_chat_inet_8h-source.html#l00194">iPort</a>, <a class="el" href="_chat_inet_8h-source.html#l00176">iSocket</a>, and <a class="el" href="_chat_inet_8h-source.html#l00170">iSocketServer</a>.<div class="fragment"><pre class="fragment"><a name="l00405"></a>00405 {<a name="l00406"></a>00406 <a class="code" href="class_c_chat_inet.html#42435def2f80909f7700ad684c625f0f">iActiveSocket</a> = &<a class="code" href="class_c_chat_inet.html#4791a9b2a2447d2068a89acb05c8c25b">iSocket</a>;<a name="l00407"></a>00407 <a class="code" href="class_c_chat_inet.html#5d2af0e4e421312918bddbe0e0861f28">iAddress</a>.SetPort( <a class="code" href="class_c_chat_inet.html#ca13b175f9849e6ff5ce23ea58682739">iPort</a> );<a name="l00408"></a>00408 <a class="code" href="class_c_chat_inet.html#5d2af0e4e421312918bddbe0e0861f28">iAddress</a>.SetAddress( aAddr );<a name="l00409"></a>00409 <a class="code" href="class_c_chat_inet.html#5d2af0e4e421312918bddbe0e0861f28">iAddress</a>.SetFamily( KAfInet );<a name="l00410"></a>00410 <a name="l00411"></a>00411 <span class="comment">// Open a TCP socket</span><a name="l00412"></a>00412 User::LeaveIfError( <a class="code" href="class_c_chat_inet.html#4791a9b2a2447d2068a89acb05c8c25b">iSocket</a>.Open( <a class="code" href="class_c_chat_inet.html#56bd53f21c6818eaa0d4a1ad2c7c5a84">iSocketServer</a>,<a name="l00413"></a>00413 KAfInet,<a name="l00414"></a>00414 KSockStream,<a name="l00415"></a>00415 KProtocolInetTcp ) );<a name="l00416"></a>00416 <a name="l00417"></a>00417 <span class="comment">// Initiate socket connection</span><a name="l00418"></a>00418 <a class="code" href="class_c_chat_inet.html#4791a9b2a2447d2068a89acb05c8c25b">iSocket</a>.Connect( <a class="code" href="class_c_chat_inet.html#5d2af0e4e421312918bddbe0e0861f28">iAddress</a>, iStatus );<a name="l00419"></a>00419 }</pre></div><p> </td> </tr></table><a class="anchor" name="79737b00f2b6a07492c7caf4220c6691"></a><!-- doxytag: member="CChatInet::DoCancel" ref="79737b00f2b6a07492c7caf4220c6691" args="()" --><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">void CChatInet::DoCancel </td> <td class="md" valign="top">( </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap><code> [protected]</code></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>DoCancel Cancel any outstanding requests <p>Reimplemented from <a class="el" href="class_c_chat_base.html#79737b00f2b6a07492c7caf4220c6691">CChatBase</a>.<p>Definition at line <a class="el" href="_chat_inet_8cpp-source.html#l00106">106</a> of file <a class="el" href="_chat_inet_8cpp-source.html">ChatInet.cpp</a>.<p>References <a class="el" href="_chat_inet_8h-source.html#l00230">iActiveSocket</a>, <a class="el" href="_chat_base_8cpp-source.html#l00130">CChatBase::SetState()</a>, and <a class="el" href="_chat_base_8cpp-source.html#l00140">CChatBase::State()</a>.<div class="fragment"><pre class="fragment"><a name="l00107"></a>00107 {<a name="l00108"></a>00108 <span class="keywordflow">if</span> ( <a class="code" href="class_c_chat_base.html#af77e92297a4bac4704e440284577ebe">State</a>() == EConnected )<a name="l00109"></a>00109 {<a name="l00110"></a>00110 <span class="keywordflow">if</span> ( <a class="code" href="class_c_chat_inet.html#42435def2f80909f7700ad684c625f0f">iActiveSocket</a> )<a name="l00111"></a>00111 {<a name="l00112"></a>00112 iActiveSocket->CancelRead();<a name="l00113"></a>00113 }<a name="l00114"></a>00114 }<a name="l00115"></a>00115 <a class="code" href="class_c_chat_base.html#deacd9f98d0548748cf116698aea2be0">SetState</a>( EDisconnected );<a name="l00116"></a>00116 }</pre></div><p> </td> </tr></table><a class="anchor" name="98dcd20e4dd117488a6a90dadd4dfac5"></a><!-- doxytag: member="CChatInet::RunL" ref="98dcd20e4dd117488a6a90dadd4dfac5" args="()" --><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">void CChatInet::RunL </td> <td class="md" valign="top">( </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap><code> [protected]</code></td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -