Blame view

JChatClient/doc/html/server_8h_source.html 19.2 KB
1
2
3
4
5
6
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.3.1"/>
7
<title>Socket: Fichero Fuente /home/imanol/devel/eclipse/PAD/JChatClient/src/include/server.h</title>
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">Socket
   </div>
   <div id="projectbrief">Librería para comunicar via TCP/IP</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generado por Doxygen 1.8.3.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Buscar');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Página&#160;principal</span></a></li>
      <li><a href="pages.html"><span>Páginas&#160;relacionadas</span></a></li>
      <li><a href="annotated.html"><span>Clases</span></a></li>
      <li class="current"><a href="files.html"><span>Archivos</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Buscar" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>Lista&#160;de&#160;archivos</span></a></li>
      <li><a href="globals.html"><span>Miembros&#160;de&#160;los&#160;ficheros</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>Todo</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Clases</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Archivos</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Funciones</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>&apos;defines&apos;</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Páginas</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
84
<li class="navelem"><a class="el" href="dir_75b82e7e4a5feb05200b9ad7adf06257.html">home</a></li><li class="navelem"><a class="el" href="dir_ade356989cf64bc7da597536eeab2615.html">imanol</a></li><li class="navelem"><a class="el" href="dir_8f7199732ad0be50edd1dbedbf9226de.html">devel</a></li><li class="navelem"><a class="el" href="dir_86dc413d07e0b16a37ceb0e2a17fed53.html">eclipse</a></li><li class="navelem"><a class="el" href="dir_c63cc34e984e21a69fd262eeef6a5cbb.html">PAD</a></li><li class="navelem"><a class="el" href="dir_74bdbd27aa6df54b6fb8f419761ac887.html">JChatClient</a></li><li class="navelem"><a class="el" href="dir_15c52bfb9a80984ec0ac7c94446ac4fc.html">src</a></li><li class="navelem"><a class="el" href="dir_c16c2f6bdf6587439d9ad3d8f0d21517.html">include</a></li>  </ul>
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">server.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="server_8h.html">Ir a la documentación de este archivo.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;</div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="preprocessor">#ifndef SERVER_H_</span></div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="preprocessor"></span><span class="preprocessor">#define SERVER_H_</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_socket_8h.html" title="Header de la clase Socket.">Socket.h</a>&quot;</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_socket_exception_8h.html" title="Header de excepción de Sockets.">SocketException.h</a>&quot;</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="preprocessor">#include &lt;iostream&gt;</span></div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="preprocessor">#include &lt;sstream&gt;</span></div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="preprocessor">#include &lt;signal.h&gt;</span></div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="preprocessor">#include &lt;fstream&gt;</span></div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;<span class="preprocessor">#include &lt;list&gt;</span></div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;<span class="preprocessor">#include &lt;fstream&gt;</span></div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;</div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;</div>
<div class="line"><a name="l00024"></a><span class="lineno"><a class="code" href="server_8h.html#a0240ac851181b84ac374872dc5434ee4">   24</a></span>&#160;<span class="preprocessor">#define N 5</span></div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;</div>
<div class="line"><a name="l00027"></a><span class="lineno"><a class="code" href="server_8h.html#ad22e7f0ef164a8dafb32f779f737a1bd">   27</a></span>&#160;<span class="preprocessor">#define CONFFILE &quot;socket.conf&quot;</span></div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;</div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;<span class="keyword">using namespace </span>std;</div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;</div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;</div>
<div class="line"><a name="l00038"></a><span class="lineno"><a class="code" href="class_server.html">   38</a></span>&#160;<span class="keyword">class </span><a class="code" href="class_server.html" title="Clase de aplicación servidor.">Server</a></div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;{</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;        <span class="keyword">private</span>:</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;</div>
<div class="line"><a name="l00044"></a><span class="lineno"><a class="code" href="class_server.html#a690955b1e335072c061df67014a6e698">   44</a></span>&#160;                <span class="keywordtype">int</span> <a class="code" href="class_server.html#a690955b1e335072c061df67014a6e698" title="Contador de threads.">nWorkers</a>;</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;</div>
<div class="line"><a name="l00048"></a><span class="lineno"><a class="code" href="class_server.html#aa9231b38adc787954a13f04372de8ed2">   48</a></span>&#160;            <span class="keywordtype">bool</span> <a class="code" href="class_server.html#aa9231b38adc787954a13f04372de8ed2" title="Variable de apagado.">shutdownServer</a>;</div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;</div>
<div class="line"><a name="l00052"></a><span class="lineno"><a class="code" href="class_server.html#ae10d91b60157ccfcc06cc463e8443007">   52</a></span>&#160;            <span class="keywordtype">int</span> <a class="code" href="class_server.html#ae10d91b60157ccfcc06cc463e8443007" title="Contador de ID de thread.">workerID</a>;</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;</div>
<div class="line"><a name="l00056"></a><span class="lineno"><a class="code" href="class_server.html#a36a18616b526f3053a1036641a62cb0a">   56</a></span>&#160;            list&lt;pthread_t*&gt; <a class="code" href="class_server.html#a36a18616b526f3053a1036641a62cb0a" title="Pila de threads terminados.">stoppedThreads</a>;</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;</div>
<div class="line"><a name="l00063"></a><span class="lineno"><a class="code" href="class_server.html#a40fdc13e227f651943e0aa3757824396">   63</a></span>&#160;            list&lt;pthread_t*&gt; <a class="code" href="class_server.html#a40fdc13e227f651943e0aa3757824396" title="Pila de threads empezados.">startedThreads</a>;</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;</div>
<div class="line"><a name="l00068"></a><span class="lineno"><a class="code" href="class_server.html#af9e1a6848bdd627741b85e75777e3b45">   68</a></span>&#160;            <a class="code" href="class_socket.html" title="Clase del socket.">Socket</a> <a class="code" href="class_server.html#af9e1a6848bdd627741b85e75777e3b45" title="Socket de comunicación.">ss</a>;</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;        <span class="keyword">public</span>:</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;</div>
<div class="line"><a name="l00073"></a><span class="lineno"><a class="code" href="class_server.html#ad5ec9462b520e59f7ea831e157ee5e59">   73</a></span>&#160;                <a class="code" href="class_server.html#ad5ec9462b520e59f7ea831e157ee5e59" title="Constructor de la clase Server.">Server</a>() : nWorkers(0), workerID(0), shutdownServer(false) {}</div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;</div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;            <span class="keywordtype">int</span> getNWorkers();</div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;</div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;            <span class="keywordtype">void</span> setNWorkers(<span class="keywordtype">int</span> n );</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;</div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;            list&lt;pthread_t*&gt;* getStartedThreads();</div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;</div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;            list&lt;pthread_t*&gt;* getStoppedThreads();</div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;</div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;            <span class="keywordtype">void</span> startServer(<span class="keywordtype">string</span> i , <span class="keywordtype">int</span> p);</div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;</div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;            <span class="keywordtype">void</span> freeRAM(list&lt;pthread_t*&gt; *threadList);</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;</div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;            <span class="keywordtype">void</span> requestExit();</div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;};</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;</div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;</div>
<div class="line"><a name="l00102"></a><span class="lineno"><a class="code" href="structthread__args.html">  102</a></span>&#160;<span class="keyword">struct </span><a class="code" href="structthread__args.html" title="Argumentos de los threads.">thread_args</a></div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;{</div>
<div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;</div>
<div class="line"><a name="l00106"></a><span class="lineno"><a class="code" href="structthread__args.html#ad5d64499f5f6e2df467c96b52a94c520">  106</a></span>&#160;    pthread_mutex_t *<a class="code" href="structthread__args.html#ad5d64499f5f6e2df467c96b52a94c520" title="Variable de control de la exclusión mútua entre threads.">mutex</a>;</div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;</div>
<div class="line"><a name="l00112"></a><span class="lineno"><a class="code" href="structthread__args.html#a96ee28beaed4175257db3d8794245f25">  112</a></span>&#160;    pthread_cond_t *<a class="code" href="structthread__args.html#a96ee28beaed4175257db3d8794245f25" title="Variable de notificación a otros threads.">condition</a>;</div>
<div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;</div>
<div class="line"><a name="l00116"></a><span class="lineno"><a class="code" href="structthread__args.html#acdcd2db4307e5e75d5110067e196a70e">  116</a></span>&#160;    pthread_t *<a class="code" href="structthread__args.html#acdcd2db4307e5e75d5110067e196a70e" title="Puntero al thread.">thread</a>;</div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;</div>
<div class="line"><a name="l00120"></a><span class="lineno"><a class="code" href="structthread__args.html#aede3ef61778d02bdf25c368d1cf9d489">  120</a></span>&#160;    <a class="code" href="class_socket.html" title="Clase del socket.">Socket</a> *<a class="code" href="structthread__args.html#aede3ef61778d02bdf25c368d1cf9d489" title="Puntero al socket.">s</a>;</div>
<div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;</div>
<div class="line"><a name="l00124"></a><span class="lineno"><a class="code" href="structthread__args.html#ab29508135b033282f374d0fb47028fbd">  124</a></span>&#160;    <a class="code" href="class_server.html" title="Clase de aplicación servidor.">Server</a> *<a class="code" href="structthread__args.html#ab29508135b033282f374d0fb47028fbd" title="Puntero al servidor.">serv</a>;</div>
<div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;</div>
<div class="line"><a name="l00127"></a><span class="lineno"><a class="code" href="structthread__args.html#a6322b3468fd88f8f49977a6439e9f352">  127</a></span>&#160;    <span class="keywordtype">int</span> <a class="code" href="structthread__args.html#a6322b3468fd88f8f49977a6439e9f352" title="ID del thread.">id</a>;</div>
<div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;};</div>
<div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;</div>
<div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;</div>
<div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;<span class="keywordtype">void</span> <a class="code" href="server_8h.html#ab99831172d1d4bca2c79bb37c7c062df" title="Método de finalización de Threads.">killThread</a>(<a class="code" href="structthread__args.html" title="Argumentos de los threads.">thread_args</a> *t_arg );</div>
<div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;</div>
<div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;<span class="keywordtype">void</span> *<a class="code" href="server_8h.html#a7d13c650ec7a525ad17cabba4f371745" title="Método gestión de conexiones.">WorkerThread</a>(<span class="keywordtype">void</span>* args );</div>
<div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;</div>
<div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;<span class="keywordtype">void</span> <a class="code" href="server_8h.html#aa6328bc358b87d3e11c3f460d6427c5b" title="Método auxiliar de procesado de texto.">processText</a>(<span class="keywordtype">string</span> *str);</div>
<div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;</div>
<div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;<span class="keywordtype">bool</span> <a class="code" href="server_8h.html#a4f850f08d755a0d0ebe936b5b84975e3" title="Método de lectura de configuración.">readConf</a>(<span class="keywordtype">string</span> *ip, <span class="keywordtype">int</span> *port);</div>
<div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;</div>
<div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;<span class="preprocessor">#endif </span><span class="comment">/* SERVER_H_ */</span><span class="preprocessor"></span></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
180
Generado el Sábado, 7 de Diciembre de 2013 01:45:57 para Socket por &#160;<a href="http://www.doxygen.org/index.html">
181
182
183
184
185
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.3.1
</small></address>
</body>
</html>