📄 listensocket_8h-source.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>listensocket.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> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> </center><hr><h1>listensocket.h</h1><div class="fragment"><pre>00001 <span class="comment">/*</span>00002 <span class="comment"> ZIG - An extendable, portable game engine focused on networking & scripting</span>00003 <span class="comment"> Project Home: http://zige.sourceforge.net</span>00004 <span class="comment"> Copyright (C) 2002 F醔io Reis Cecin <fcecin AT inf DOT ufrgs DOT br></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"> listen-socket: an NL thread running an NL TCP listen-socket's accept() call</span>00023 <span class="comment"></span>00024 <span class="comment">*/</span>00025 00026 <span class="preprocessor">#ifndef _ZIG_HEADER_LISTENSOCKET_H_</span>00027 <span class="preprocessor"></span><span class="preprocessor">#define _ZIG_HEADER_LISTENSOCKET_H_</span>00028 <span class="preprocessor"></span>00029 <span class="preprocessor">#ifndef NO_DOXYGEN // internal class -- do not document</span>00030 <span class="preprocessor"></span>00031 <span class="preprocessor">#include <nl.h></span>00032 <span class="preprocessor">#include "leetnet.h"</span>00033 <span class="preprocessor">#include "thread.h"</span>00034 <span class="preprocessor">#include "console.h"</span>00035 00036 <span class="keyword">class </span>leet_c;00037 00038 <span class="keyword">class </span>listen_socket_c {00039 <span class="keyword">public</span>:00040 00041 <span class="comment">//create the listen socket object</span>00042 listen_socket_c() { sock = NL_INVALID; port = 0; listener = 0; }00043 00044 <span class="comment">//dtor</span>00045 <span class="keyword">virtual</span> ~listen_socket_c() { stop(); }00046 00047 <span class="comment">//set console</span>00048 <span class="keywordtype">void</span> set_console(<a class="code" href="classconsole__c.html">console_c</a> *conio) { con = conio; }00049 00050 <span class="comment">//set listener (leet client/server)</span>00051 <span class="keywordtype">void</span> set_listener(leet_c *listener) { this->listener = listener; }00052 00053 <span class="comment">//set port number</span>00054 <span class="keywordtype">void</span> set_port(<span class="keywordtype">int</span> portnum) { port = portnum; }00055 00056 <span class="comment">//listen at previously set_port()-given port number. returns false on error.</span>00057 <span class="keywordtype">bool</span> listen();00058 00059 <span class="comment">//listen at given port number. returns false on error.</span>00060 <span class="keywordtype">bool</span> listen(<span class="keywordtype">int</span> portnum) { set_port(portnum); <span class="keywordflow">return</span> listen(); }00061 00062 <span class="comment">//stop listening</span>00063 <span class="keywordtype">void</span> stop();00064 00065 <span class="comment">//----called by the thread----------</span>00066 00067 <span class="comment">//do the listening</span>00068 <span class="keywordtype">void</span>* listen_thread_run(<span class="keywordtype">void</span> *);00069 00070 <span class="keyword">protected</span>:00071 00072 <span class="comment">//mutex for stop() method</span>00073 mutex_c stop_mutex;00074 00075 <span class="comment">//the thread</span>00076 thread_c<listen_socket_c> th;00077 00078 <span class="comment">//the socket</span>00079 NLsocket sock;00080 mutex_c sock_mutex; <span class="comment">//mutex for accessing sock handle</span>00081 00082 <span class="comment">//the port</span>00083 <span class="keywordtype">int</span> port;00084 00085 <span class="comment">//tell thread to join</span>00086 <span class="keyword">volatile</span> <span class="keywordtype">bool</span> quit_listening;00087 00088 <span class="comment">//the listener</span>00089 leet_c *listener;00090 00091 <span class="comment">//console</span>00092 <a class="code" href="classconsole__c.html">console_c</a> *con;00093 };00094 <span class="preprocessor">#endif //#ifndef NO_DOXYGEN // internal class -- do not document</span>00095 <span class="preprocessor"></span>00096 <span class="preprocessor">#endif </span>00097 <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 + -