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

📄 channel_8h-source.html

📁 用来介绍ZIG Library游戏网络引擎的文档
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>channel.h Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.2.18 --><center><a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; </center><hr><h1>channel.h</h1><div class="fragment"><pre>00001 <span class="comment">/*</span>00002 <span class="comment">    ZIG - An extendable, portable game engine focused on networking &amp; scripting</span>00003 <span class="comment">    Project Home: http://zige.sourceforge.net</span>00004 <span class="comment">    Copyright (C) 2002  F醔io Reis Cecin &lt;fcecin AT inf DOT ufrgs DOT br&gt;</span>00005 <span class="comment"></span>00006 <span class="comment">    This library is free software; you can redistribute it and/or</span>00007 <span class="comment">    modify it under the terms of the GNU Lesser General Public</span>00008 <span class="comment">    License as published by the Free Software Foundation; either</span>00009 <span class="comment">    version 2.1 of the License, or (at your option) any later version.</span>00010 <span class="comment"></span>00011 <span class="comment">    This library is distributed in the hope that it will be useful,</span>00012 <span class="comment">    but WITHOUT ANY WARRANTY; without even the implied warranty of</span>00013 <span class="comment">    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU</span>00014 <span class="comment">    Lesser General Public License for more details.</span>00015 <span class="comment"></span>00016 <span class="comment">    You should have received a copy of the GNU Lesser General Public</span>00017 <span class="comment">    License along with this library; if not, write to the Free Software</span>00018 <span class="comment">    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   </span>00019 <span class="comment">*/</span>00020 <span class="comment">/*</span>00021 <span class="comment"></span>00022 <span class="comment">        LEETNET 2</span>00023 <span class="comment"></span>00024 <span class="comment">        channel is a wrapper to a TCP socket OR an LEET-UDP emulated TCP socket (in the</span>00025 <span class="comment">        rare event of a firewall on both sides that lets UDP pass but not TCP !?!?)</span>00026 <span class="comment"></span>00027 <span class="comment">*/</span>00028 00029 <span class="preprocessor">#ifndef _ZIG_HEADER_CHANNEL_H_</span>00030 <span class="preprocessor"></span><span class="preprocessor">#define _ZIG_HEADER_CHANNEL_H_</span>00031 <span class="preprocessor"></span>00032 <span class="preprocessor">#include &lt;nl.h&gt;</span>00033 <span class="preprocessor">#include "buffer.h"</span>00034 <span class="preprocessor">#include "console.h"</span>00035 <span class="preprocessor">#include "thread.h"</span>00036 00037 <span class="preprocessor">#include &lt;string&gt;</span>00038 <a name="l00040"></a><a class="code" href="classchannel__c.html">00040</a> <span class="keyword">class </span><a class="code" href="classchannel__c.html">channel_c</a> {00041 <span class="keyword">public</span>:00042 00043         <span class="comment">//ctor - create a channel associated to a TCP socket</span>00044         <a class="code" href="classchannel__c.html">channel_c</a>(NLsocket sock);00045 00046         <span class="comment">//ctor - no socket yet</span>00047         <a class="code" href="classchannel__c.html">channel_c</a>();00048 <a name="l00050"></a><a class="code" href="classchannel__c.html#a2">00050</a>         <span class="keywordtype">void</span> <a class="code" href="classchannel__c.html#a2">set_keep_open</a>(<span class="keywordtype">bool</span> val) { keep_open = val; }00051 <a name="l00053"></a><a class="code" href="classchannel__c.html#a3">00053</a>         <span class="keywordtype">bool</span> <a class="code" href="classchannel__c.html#a3">get_keep_open</a>() { <span class="keywordflow">return</span> keep_open; }00054 00055         <span class="comment">//set TCP socket</span>00056         <span class="keywordtype">void</span> set_socket(NLsocket sock);00057 00058         <span class="comment">//set console for debugging</span>00059         <span class="keywordtype">void</span> set_console(<a class="code" href="classconsole__c.html">console_c</a> *conio) { con = conio; }00060 00061         <span class="comment">//dtor</span>00062         <span class="keyword">virtual</span> ~<a class="code" href="classchannel__c.html">channel_c</a>();00063 00071         <span class="keywordtype">int</span> <a class="code" href="classchannel__c.html#a7">write</a>(<a class="code" href="classbuffer__c.html">buffer_c</a> &amp;out, <span class="keywordtype">bool</span> timeout_is_failure = <span class="keyword">true</span>, <span class="keywordtype">double</span> timeout = 3.0);00072 00074         <span class="keywordtype">int</span> <a class="code" href="classchannel__c.html#a8">read</a>(<a class="code" href="classbuffer__c.html">buffer_c</a> &amp;in, <span class="keywordtype">int</span> size);00075 00082         <span class="keywordtype">int</span> <a class="code" href="classchannel__c.html#a9">read_string</a>(std::string &amp;str, <span class="keywordtype">int</span> maxsize = -1);00083 00089         <span class="keywordtype">void</span> <a class="code" href="classchannel__c.html#a10">close</a>();00090 <a name="l00092"></a><a class="code" href="classchannel__c.html#a11">00092</a>         <span class="keywordtype">bool</span> <a class="code" href="classchannel__c.html#a11">is_closed</a>() { <span class="keywordflow">return</span> closing_flag; }00093 00094 <span class="keyword">protected</span>:00095 00096         <span class="comment">//option: keep channel opened </span>00097         <span class="keywordtype">bool</span> keep_open;00098 00099         <span class="comment">//closing flag set to TRUE after first call to close()</span>00100         <span class="keyword">volatile</span> <span class="keywordtype">bool</span> closing_flag;00101 00102         <span class="comment">//the TCP socket - a copyable var</span>00103         NLsocket sock;00104 00105         <span class="comment">//console for debugging - a fairly copyable var...</span>00106         <a class="code" href="classconsole__c.html">console_c</a> *con;00107 00108 <span class="keyword">private</span>:00109         00111         <a class="code" href="classchannel__c.html">channel_c</a>(<span class="keyword">const</span> <a class="code" href="classchannel__c.html">channel_c</a> &amp;) {};00112 00114         <a class="code" href="classchannel__c.html">channel_c</a> &amp;operator=(<span class="keyword">const</span> <a class="code" href="classchannel__c.html">channel_c</a> &amp;);00115 };00116 00117 00118 <span class="preprocessor">#endif</span>00119 <span class="preprocessor"></span></pre></div><hr><address style="align: right;"><small>Generated on Mon Jan 24 21:14:23 2005 for ZIG by<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border=0 width=110 height=53></a>1.2.18 </small></address></body></html>

⌨️ 快捷键说明

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