aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/buf__sock_8h-source.html
blob: dd850a235f1ba7e1a72d4daefb26901ad64c1989 (plain)
1
2
3
4
5
6
7
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
84
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
	<TITLE>nevrax.org : docs</TITLE>
	<LINK REL=stylesheet TYPE="text/css" HREF="http://www.nevrax.org/inc/css/nevrax.css">
	<link href="doxygen.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY MARGINHEIGHT="0" MARGINWIDTH="0">

<!-- uplinks -->
<TABLE CELLSPACING=0 CELLPADDING=0  BORDER=0>
 <TR>
        <TD WIDTH=16><IMG  SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD WIDTH=140 BGCOLOR=#dddddd><IMG  SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD WIDTH=16><IMG  SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
        <TD><IMG  width=6 height=14  SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
 </TR>
</TABLE> 

<!-- banner Nevrax -->
<TABLE CELLSPACING=0 CELLPADDING=0  BORDER=0 WIDTH=100%>
 <TR><TD  BGCOLOR="#000000" BACKGROUND="http://www.nevrax.org/inc/img/black_banner.jpg"><A HREF="http://www.nevrax.org"><IMG  SRC="http://www.nevrax.org/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR>
</TABLE>

<!-- main table -->
<TABLE CELLSPACING=0 CELLPADDING=0  BORDER=0 height=100%>
 <TR>
	<TD WIDTH=16><IMG  SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
	<TD WIDTH=140   BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG  SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">

		<!------ Begin Box ------>
		<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0  cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black>
		<FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td  colspan=2 bgcolor=#FFFFFF>
		<TABLE cellspacing=0 cellpadding=1 border=0>
			<tr><td ALIGN=middle><a  class='linkbox' href="http://www.nevrax.org/news/" TITLE="Rubrique news"><img width=13 height=15  hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-news.gif ALT=#></A></td><td><a  class='linkbox' href="http://www.nevrax.org/news/" TITLE="News">News</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Rubrique mail"><img width=15 height=11  hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-mail.gif ALT=#></A></td><td><a  class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Rubrique docs"><img width=14 height=16  hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-docs.gif ALT=#></A></td><td><a  class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Documentation">Documentation</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="Rubrique cvs"><img width=13 height=17  hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-cvs.gif ALT=#></A></td><td><a  class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="CVS Web">CVS</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Rubrique bugs"><img width=20 height=16  hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-bugs.gif ALT=#></A></td><td><a  class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="Rubrique license"><img  width=18 height=12   hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-gpl.gif ALT=#></A></td><td><a  class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="License">License</a></td></tr>
		</TABLE>
		</TD></TR></TABLE></TD></TR></TABLE>
		<!------ End Box  ------>

	</TD>
	<TD WIDTH=15><IMG  SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
	<TD ALIGN=left valign=top><IMG  SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">

<!-- title -->
<TABLE  background="http://www.nevrax.org/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0  BORDER=0 width=100%><tr><td>
<A HREF="http://www.nevrax.org/docs/"><img src="http://www.nevrax.org/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
</td><td><IMG  SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT="">
</td></tr></table>
&nbsp;

<!-- block -->
<TABLE  bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0  BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="http://www.nevrax.org/inc/img/reddots.gif"></TD>
	<TD><B>Documentation</B></TD>
	<TD ALIGN=RIGHT>&nbsp;</td>
</tr></table>
<!-- Generated by Doxygen 1.2.14 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</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="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; <a class="qindexRef" doxygen="_cgi:http://www.nevrax.org/cgi-bin/nel-search.cgi" href="http://www.nevrax.org/cgi-bin/nel-search.cgi">Search</a> &nbsp; </center>
<hr><h1>buf_sock.h</h1><a href="buf__sock_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 
00007 <font class="comment">/* Copyright, 2001 Nevrax Ltd.</font>
00008 <font class="comment"> *</font>
00009 <font class="comment"> * This file is part of NEVRAX NEL.</font>
00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
00013 <font class="comment"> * any later version.</font>
00014 <font class="comment"></font>
00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
00018 <font class="comment"> * General Public License for more details.</font>
00019 <font class="comment"></font>
00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
00023 <font class="comment"> * MA 02111-1307, USA.</font>
00024 <font class="comment"> */</font>
00025 
00026 <font class="preprocessor">#ifndef NL_BUF_SOCK_H</font>
00027 <font class="preprocessor"></font><font class="preprocessor">#define NL_BUF_SOCK_H</font>
00028 <font class="preprocessor"></font>
00029 <font class="preprocessor">#include "<a class="code" href="types__nl_8h.html">nel/misc/types_nl.h</a>"</font>
00030 <font class="preprocessor">#include "<a class="code" href="hierarchical__timer_8h.html">nel/misc/hierarchical_timer.h</a>"</font>
00031 
00032 <font class="preprocessor">#include "<a class="code" href="buf__net__base_8h.html">nel/net/buf_net_base.h</a>"</font>
00033 <font class="preprocessor">#include "<a class="code" href="tcp__sock_8h.html">nel/net/tcp_sock.h</a>"</font>
00034 
00035 <font class="comment">//#include &lt;deque&gt;</font>
00036 
00037 <font class="keyword">namespace </font>NLNET {
00038 
00039 
<a name="l00040"></a><a class="code" href="buf__sock_8h.html#a0">00040</a> <font class="preprocessor">#define nlnettrace(__msg) //nldebug("LNETL1: %s",__msg);</font>
00041 <font class="preprocessor"></font>
00042 
00043 <font class="keyword">class </font>CTcpSock;
00044 
00045 <font class="keyword">class </font>CBufNetBase;
00046 
00047 
<a name="l00052"></a><a class="code" href="classNLNET_1_1CBufSock.html">00052</a> <font class="keyword">class </font>CBufSock
00053 {
00054 <font class="keyword">public</font>:
00055 
00057         <font class="keyword">virtual</font> <a class="code" href="classNLNET_1_1CBufSock.html#a0">~CBufSock</a>();
00058 
<a name="l00060"></a><a class="code" href="classNLNET_1_1CBufSock.html#a1">00060</a>         <font class="keywordtype">void</font>                                    <a class="code" href="classNLNET_1_1CBufSock.html#a1">setAppId</a>( uint64 <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a> ) { <a class="code" href="classNLNET_1_1CBufSock.html#o5">_AppId</a> = <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>; }
00061 
<a name="l00063"></a><a class="code" href="classNLNET_1_1CBufSock.html#a2">00063</a>         uint64                                  <a class="code" href="classNLNET_1_1CBufSock.html#a2">appId</a>()<font class="keyword"> const </font>{ <font class="keywordflow">return</font> <a class="code" href="classNLNET_1_1CBufSock.html#o5">_AppId</a>; }
00064 
00066         std::string                             <a class="code" href="classNLNET_1_1CBufSock.html#a3">asString</a>() <font class="keyword">const</font>;
00067 
<a name="l00070"></a><a class="code" href="classNLNET_1_1CBufSock.html#m0">00070</a>         std::string                             <a class="code" href="classNLNET_1_1CBufSock.html#m0">AuthorizedCallback</a>;
00071 
00072         <font class="comment">// debug features, we number all packet to be sure that they are all sent and received</font>
00073         <font class="comment">// \todo remove this debug feature when ok</font>
<a name="l00074"></a><a class="code" href="classNLNET_1_1CBufSock.html#m1">00074</a>         uint32                                  <a class="code" href="classNLNET_1_1CBufSock.html#m1">SendNextValue</a>, <a class="code" href="classNLNET_1_1CBufSock.html#m2">ReceiveNextValue</a>;
00075 
00076 <font class="keyword">protected</font>:
00077 
<a name="l00078"></a><a class="code" href="classNLNET_1_1CBufSock.html#l0">00078</a>         <font class="keyword">friend</font> <font class="keyword">class </font><a class="code" href="classNLNET_1_1CBufSock.html#l0">CBufClient</a>;
<a name="l00079"></a><a class="code" href="classNLNET_1_1CBufSock.html#l1">00079</a>         <font class="keyword">friend</font> <font class="keyword">class </font><a class="code" href="classNLNET_1_1CBufSock.html#l1">CBufServer</a>;
<a name="l00080"></a><a class="code" href="classNLNET_1_1CBufSock.html#l2">00080</a>         <font class="keyword">friend</font> <font class="keyword">class </font><a class="code" href="classNLNET_1_1CBufSock.html#l2">CClientReceiveTask</a>;
<a name="l00081"></a><a class="code" href="classNLNET_1_1CBufSock.html#l3">00081</a>         <font class="keyword">friend</font> <font class="keyword">class </font><a class="code" href="classNLNET_1_1CBufSock.html#l3">CServerReceiveTask</a>;
00082 
<a name="l00083"></a><a class="code" href="classNLNET_1_1CBufSock.html#l4">00083</a>         <font class="keyword">friend</font> <font class="keyword">class </font><a class="code" href="classNLNET_1_1CBufSock.html#l4">CCallbackClient</a>;
<a name="l00084"></a><a class="code" href="classNLNET_1_1CBufSock.html#l5">00084</a>         <font class="keyword">friend</font> <font class="keyword">class </font><a class="code" href="classNLNET_1_1CBufSock.html#l5">CCallbackServer</a>;
<a name="l00085"></a><a class="code" href="classNLNET_1_1CBufSock.html#l6">00085</a>         <font class="keyword">friend</font> <font class="keyword">class </font><a class="code" href="classNLNET_1_1CBufSock.html#l6">CCallbackNetBase</a>;
00086 
00088         <a class="code" href="classNLNET_1_1CBufSock.html#b0">CBufSock</a>( CTcpSock *sock=NULL );
00089 
00091 
00092         
00094         <font class="keywordtype">bool</font>    <a class="code" href="classNLNET_1_1CBufSock.html#z347_0">update</a>();
00095 
00099         <font class="keywordtype">void</font>    <a class="code" href="classNLNET_1_1CBufSock.html#z347_1">setTimeFlushTrigger</a>( sint32 ms );
00100 
<a name="l00104"></a><a class="code" href="classNLNET_1_1CBufSock.html#z347_2">00104</a>         <font class="keywordtype">void</font>    <a class="code" href="classNLNET_1_1CBufSock.html#z347_2">setSizeFlushTrigger</a>( sint32 size ) { <a class="code" href="classNLNET_1_1CBufSock.html#o2">_TriggerSize</a> = size; }
00105 
00110         <font class="keywordtype">bool</font>    <a class="code" href="classNLNET_1_1CBufSock.html#z347_3">flush</a>();
00111 
00113 
<a name="l00115"></a><a class="code" href="classNLNET_1_1CBufSock.html#b1">00115</a>         <font class="keyword">virtual</font> std::string <a class="code" href="classNLNET_1_1CBufSock.html#b1">typeStr</a>()<font class="keyword"> const </font>{ <font class="keywordflow">return</font> <font class="stringliteral">"CLT "</font>; }
00116 
<a name="l00120"></a><a class="code" href="classNLNET_1_1CBufSock.html#b2">00120</a>         <font class="keywordtype">bool</font> <a class="code" href="classNLNET_1_1CBufSock.html#b2">advertiseDisconnection</a>( CBufNetBase *bnb, <a class="code" href="namespaceNLNET.html#a0">TSockId</a> sockid )
00121         {
00122 <font class="preprocessor">#ifdef NL_DEBUG</font>
00123 <font class="preprocessor"></font>                <font class="keywordflow">if</font> ( sockid != InvalidSockId )
00124                 {
00125                         <a class="code" href="debug_8h.html#a6">nlassert</a>( sockid == <font class="keyword">this</font> );
00126                 }
00127 <font class="preprocessor">#endif</font>
00128 <font class="preprocessor"></font>                <font class="keywordflow">return</font> <a class="code" href="classNLNET_1_1CBufSock.html#b3">advertiseSystemEvent</a>( bnb, sockid, <a class="code" href="classNLNET_1_1CBufSock.html#n2">_KnowConnected</a>, <font class="keyword">true</font>, CBufNetBase::Disconnection );
00129         }
00130 
00131         
<a name="l00135"></a><a class="code" href="classNLNET_1_1CBufSock.html#b3">00135</a>         <font class="keywordtype">bool</font> <a class="code" href="classNLNET_1_1CBufSock.html#b3">advertiseSystemEvent</a>(
00136                 CBufNetBase *bnb, <a class="code" href="namespaceNLNET.html#a0">TSockId</a> sockid, <font class="keywordtype">bool</font>&amp; flag, <font class="keywordtype">bool</font> <a class="code" href="driver__opengl__extension__def_8h.html#a376">condition</a>, CBufNetBase::TEventType event )
00137         {
00138 <font class="preprocessor">#ifdef NL_DEBUG</font>
00139 <font class="preprocessor"></font>                <font class="keywordflow">if</font> ( sockid != InvalidSockId )
00140                 {
00141                         <a class="code" href="debug_8h.html#a6">nlassert</a>( sockid == <font class="keyword">this</font> );
00142                 }
00143 <font class="preprocessor">#endif</font>
00144 <font class="preprocessor"></font>                <font class="comment">// Test flag</font>
00145                 <font class="keywordflow">if</font> ( flag==<a class="code" href="driver__opengl__extension__def_8h.html#a376">condition</a> )
00146                 {
00147                         <a class="code" href="debug_8h.html#a0">nldebug</a>( <font class="stringliteral">"Pushing event to %s"</font>, <a class="code" href="classNLNET_1_1CBufSock.html#a3">asString</a>().c_str() );
00148                         std::vector&lt;uint8&gt; buffer;
00149                         <font class="keywordflow">if</font> ( sockid == InvalidSockId )
00150                         {
00151                                 <font class="comment">// Client: event type only</font>
00152                                 buffer.resize( 1 );
00153                                 buffer[0] = event;
00154                         }
00155                         <font class="keywordflow">else</font>
00156                         {
00157                                 <font class="comment">// Server: sockid + event type</font>
00158                                 buffer.resize( <font class="keyword">sizeof</font>(<a class="code" href="namespaceNLNET.html#a0">TSockId</a>) + 1 );
00159                                 memcpy( &amp;*buffer.begin(), &amp;sockid, <font class="keyword">sizeof</font>(TSockId) );
00160                                 buffer[<font class="keyword">sizeof</font>(TSockId)] = event;
00161                         }
00162                         <font class="comment">// Push</font>
00163                         bnb-&gt;pushMessageIntoReceiveQueue( buffer );
00164 
00165                         <font class="comment">// Reset flag</font>
00166                         flag = !<a class="code" href="driver__opengl__extension__def_8h.html#a376">condition</a>;
00167                         <font class="keywordflow">return</font> <font class="keyword">true</font>;
00168                 }
00169                 <font class="keywordflow">else</font>
00170                 {
00171                         <font class="keywordflow">return</font> <font class="keyword">false</font>;
00172                 }
00173         }
00174 
<a name="l00178"></a><a class="code" href="classNLNET_1_1CBufSock.html#b4">00178</a>         <font class="keywordtype">bool</font> <a class="code" href="classNLNET_1_1CBufSock.html#b4">pushBuffer</a>( <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CMemStream.html">NLMISC::CMemStream</a>&amp; buffer )
00179         {
00180                 <a class="code" href="debug_8h.html#a6">nlassert</a> (<font class="keyword">this</font> != InvalidSockId);       <font class="comment">// invalid bufsock</font>
00181 <font class="comment">//              nldebug( "LNETL1: Pushing buffer to %s", asString().c_str() );</font>
00182 
00183                 <font class="keyword">static</font> uint32 biggerBufferSize = 64000;
00184                 <font class="keywordflow">if</font> (buffer.<a class="code" href="classNLMISC_1_1CMemStream.html#a10">length</a>() &gt; biggerBufferSize)
00185                 {
00186                         biggerBufferSize = buffer.<a class="code" href="classNLMISC_1_1CMemStream.html#a10">length</a>();
00187                         <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"LNETL1: new record! bigger network message pushed (sent) is %u bytes"</font>, biggerBufferSize);
00188                 }
00189 
00190                 <font class="keywordflow">if</font> ( <a class="code" href="classNLNET_1_1CBufSock.html#n1">Sock</a>-&gt;connected() )
00191                 {
00192                         <font class="comment">// Push into host's send queue</font>
00193                         <a class="code" href="classNLNET_1_1CBufSock.html#n0">SendFifo</a>.<a class="code" href="classNLMISC_1_1CBufFIFO.html#a2">push</a>( buffer );
00194 
00195                         <font class="comment">// Update sending</font>
00196                         <font class="keywordtype">bool</font> <a class="code" href="driver__opengl__extension__def_8h.html#a400">res</a> = <a class="code" href="classNLNET_1_1CBufSock.html#z347_0">update</a> ();
00197                         <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a400">res</a>; <font class="comment">// not checking the result as in CBufServer::update()</font>
00198                 }
00199                 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00200         }
00201 
00202         <font class="comment">/*bool pushBuffer( const std::vector&lt;uint8&gt;&amp; buffer )</font>
00203 <font class="comment">        {</font>
00204 <font class="comment">                nlassert (this != InvalidSockId);       // invalid bufsock</font>
00205 <font class="comment">//              nldebug( "LNETL1: Pushing buffer to %s", asString().c_str() );</font>
00206 <font class="comment"></font>
00207 <font class="comment">                static uint32 biggerBufferSize = 64000;</font>
00208 <font class="comment">                if (buffer.size() &gt; biggerBufferSize)</font>
00209 <font class="comment">                {</font>
00210 <font class="comment">                        biggerBufferSize = buffer.size();</font>
00211 <font class="comment">                        nlwarning ("LNETL1: new record! bigger network message pushed (sent) is %u bytes", biggerBufferSize);</font>
00212 <font class="comment">                }</font>
00213 <font class="comment"></font>
00214 <font class="comment">                if ( Sock-&gt;connected() )</font>
00215 <font class="comment">                {</font>
00216 <font class="comment">                        // Push into host's send queue</font>
00217 <font class="comment">                        SendFifo.push( buffer );</font>
00218 <font class="comment"></font>
00219 <font class="comment">                        // Update sending</font>
00220 <font class="comment">                        bool res = update ();</font>
00221 <font class="comment">                        return res; // not checking the result as in CBufServer::update()</font>
00222 <font class="comment">                }</font>
00223 <font class="comment">                return false;</font>
00224 <font class="comment">        }*/</font>
00225 
00226 
00228         <font class="keywordtype">void</font> <a class="code" href="classNLNET_1_1CBufSock.html#b5">connect</a>( <font class="keyword">const</font> CInetAddress&amp; <a class="code" href="driver__opengl__extension__def_8h.html#a414">addr</a>, <font class="keywordtype">bool</font> nodelay, <font class="keywordtype">bool</font> connectedstate );
00229 
00231         <font class="keywordtype">void</font> <a class="code" href="classNLNET_1_1CBufSock.html#b6">disconnect</a>( <font class="keywordtype">bool</font> connectedstate );
00232 
<a name="l00234"></a><a class="code" href="classNLNET_1_1CBufSock.html#b7">00234</a>         <font class="keywordtype">void</font> <a class="code" href="classNLNET_1_1CBufSock.html#b7">setConnectedState</a>( <font class="keywordtype">bool</font> connectedstate ) { <a class="code" href="classNLNET_1_1CBufSock.html#o6">_ConnectedState</a> = connectedstate; } 
00235 
<a name="l00237"></a><a class="code" href="classNLNET_1_1CBufSock.html#b8">00237</a>         <font class="keywordtype">bool</font> <a class="code" href="classNLNET_1_1CBufSock.html#b8">connectedState</a>()<font class="keyword"> const </font>{ <font class="keywordflow">return</font> <a class="code" href="classNLNET_1_1CBufSock.html#o6">_ConnectedState</a>; }
00238 
00239         <font class="comment">// Send queue</font>
<a name="l00240"></a><a class="code" href="classNLNET_1_1CBufSock.html#n0">00240</a>         <a class="code" href="classNLMISC_1_1CBufFIFO.html">NLMISC::CBufFIFO</a>        <a class="code" href="classNLNET_1_1CBufSock.html#n0">SendFifo</a>;
00241 
00242         <font class="comment">// Socket (pointer because it can be allocated by an accept())</font>
<a name="l00243"></a><a class="code" href="classNLNET_1_1CBufSock.html#n1">00243</a>         CTcpSock                        *<a class="code" href="classNLNET_1_1CBufSock.html#n1">Sock</a>;
00244 
00245         <font class="comment">// Prevents from pushing a connection/disconnection event twice</font>
<a name="l00246"></a><a class="code" href="classNLNET_1_1CBufSock.html#n2">00246</a>         <font class="keywordtype">bool</font>                            <a class="code" href="classNLNET_1_1CBufSock.html#n2">_KnowConnected</a>;
00247 
00248 <font class="keyword">private</font>:
00249 
00250 <font class="preprocessor">#ifdef NL_DEBUG</font>
00251 <font class="preprocessor"></font>        <font class="keyword">enum</font> TFlushTrigger { FTTime, FTSize, FTManual };
00252         TFlushTrigger           _FlushTrigger;
00253 <font class="preprocessor">#endif</font>
00254 <font class="preprocessor"></font>
<a name="l00255"></a><a class="code" href="classNLNET_1_1CBufSock.html#o0">00255</a>         NLMISC::TTime           <a class="code" href="classNLNET_1_1CBufSock.html#o0">_LastFlushTime</a>; <font class="comment">// updated only if time trigger is enabled (TriggerTime!=-1)</font>
<a name="l00256"></a><a class="code" href="classNLNET_1_1CBufSock.html#o1">00256</a>         NLMISC::TTime           <a class="code" href="classNLNET_1_1CBufSock.html#o1">_TriggerTime</a>;
<a name="l00257"></a><a class="code" href="classNLNET_1_1CBufSock.html#o2">00257</a>         sint32                          <a class="code" href="classNLNET_1_1CBufSock.html#o2">_TriggerSize</a>;
00258 
<a name="l00259"></a><a class="code" href="classNLNET_1_1CBufSock.html#o3">00259</a>         <a class="code" href="classNLMISC_1_1CObjectVector.html">NLMISC::CObjectVector&lt;uint8&gt;</a> <a class="code" href="classNLNET_1_1CBufSock.html#o3">_ReadyToSendBuffer</a>;
<a name="l00260"></a><a class="code" href="classNLNET_1_1CBufSock.html#o4">00260</a>         <a class="code" href="namespaceNLNET.html#a6">TBlockSize</a>                      <a class="code" href="classNLNET_1_1CBufSock.html#o4">_RTSBIndex</a>;
00261 
<a name="l00262"></a><a class="code" href="classNLNET_1_1CBufSock.html#o5">00262</a>         uint64                          <a class="code" href="classNLNET_1_1CBufSock.html#o5">_AppId</a>;
00263 
00264         <font class="comment">// Connected state (from the user's point of view, i.e. changed when the connection/disconnection event is at the front of the receive queue)</font>
<a name="l00265"></a><a class="code" href="classNLNET_1_1CBufSock.html#o6">00265</a>         <font class="keywordtype">bool</font>                            <a class="code" href="classNLNET_1_1CBufSock.html#o6">_ConnectedState</a>;
00266 };
00267 
00268 
00269 <font class="keyword">class </font>CBufServer;
00270 
00271 
<a name="l00276"></a><a class="code" href="classNLNET_1_1CServerBufSock.html">00276</a> <font class="keyword">class </font>CServerBufSock : <font class="keyword">public</font> CBufSock
00277 {
00278 <font class="keyword">protected</font>:
00279 
<a name="l00280"></a><a class="code" href="classNLNET_1_1CServerBufSock.html#l0">00280</a>         <font class="keyword">friend</font> <font class="keyword">class </font><a class="code" href="classNLNET_1_1CServerBufSock.html#l0">CBufServer</a>;
<a name="l00281"></a><a class="code" href="classNLNET_1_1CServerBufSock.html#l1">00281</a>         <font class="keyword">friend</font> <font class="keyword">class </font><a class="code" href="classNLNET_1_1CServerBufSock.html#l1">CListenTask</a>;
<a name="l00282"></a><a class="code" href="classNLNET_1_1CServerBufSock.html#l2">00282</a>         <font class="keyword">friend</font> <font class="keyword">class </font><a class="code" href="classNLNET_1_1CServerBufSock.html#l2">CServerReceiveTask</a>;
00283 
00287         <a class="code" href="classNLNET_1_1CServerBufSock.html#b0">CServerBufSock</a>( CTcpSock *sock );
00288 
<a name="l00290"></a><a class="code" href="classNLNET_1_1CServerBufSock.html#b1">00290</a>         <font class="keywordtype">void</font>                                            <a class="code" href="classNLNET_1_1CServerBufSock.html#b1">setOwnerTask</a>( <a class="code" href="classNLNET_1_1CServerBufSock.html#l2">CServerReceiveTask</a>* owner ) { <a class="code" href="classNLNET_1_1CServerBufSock.html#o5">_OwnerTask</a> = owner; }
00291 
<a name="l00293"></a><a class="code" href="classNLNET_1_1CServerBufSock.html#b2">00293</a>         <a class="code" href="classNLNET_1_1CServerBufSock.html#l2">CServerReceiveTask</a>                      *<a class="code" href="classNLNET_1_1CServerBufSock.html#b2">ownerTask</a>() { <font class="keywordflow">return</font> <a class="code" href="classNLNET_1_1CServerBufSock.html#o5">_OwnerTask</a>; }
00294 
00298         <font class="keywordtype">bool</font>                                            <a class="code" href="classNLNET_1_1CServerBufSock.html#b3">receivePart</a>();
00299 
<a name="l00301"></a><a class="code" href="classNLNET_1_1CServerBufSock.html#b4">00301</a>         <font class="keyword">const</font> std::vector&lt;uint8&gt;        <a class="code" href="classNLNET_1_1CServerBufSock.html#b4">receivedBuffer</a>()<font class="keyword"> const </font>{ <a class="code" href="buf__sock_8h.html#a0">nlnettrace</a>( <font class="stringliteral">"CServerBufSock::receivedBuffer"</font> ); <font class="keywordflow">return</font> <a class="code" href="classNLNET_1_1CServerBufSock.html#o4">_ReceiveBuffer</a>; }
00302 
<a name="l00306"></a><a class="code" href="classNLNET_1_1CServerBufSock.html#b5">00306</a>         <font class="keywordtype">bool</font>                                            <a class="code" href="classNLNET_1_1CServerBufSock.html#b5">advertiseConnection</a>( <a class="code" href="classNLNET_1_1CServerBufSock.html#l0">CBufServer</a> *bnb )
00307         {
00308                 <font class="keywordflow">return</font> <a class="code" href="classNLNET_1_1CBufSock.html#b3">advertiseSystemEvent</a>( (CBufNetBase*)bnb, <font class="keyword">this</font>, <a class="code" href="classNLNET_1_1CBufSock.html#n2">_KnowConnected</a>, <font class="keyword">false</font>, CBufNetBase::Connection );
00309         }
00310 
<a name="l00312"></a><a class="code" href="classNLNET_1_1CServerBufSock.html#b6">00312</a>         <font class="keyword">virtual</font> std::string                     <a class="code" href="classNLNET_1_1CServerBufSock.html#b6">typeStr</a>()<font class="keyword"> const </font>{ <font class="keywordflow">return</font> <font class="stringliteral">"SRV "</font>; }
00313 
00314 <font class="keyword">private</font>:
00315 
<a name="l00317"></a><a class="code" href="classNLNET_1_1CServerBufSock.html#o0">00317</a>         <font class="keywordtype">bool</font>                            <a class="code" href="classNLNET_1_1CServerBufSock.html#o0">_Advertised</a>;
00318 
00319         <font class="comment">// True if the length prefix has already been read</font>
<a name="l00320"></a><a class="code" href="classNLNET_1_1CServerBufSock.html#o1">00320</a>         <font class="keywordtype">bool</font>                            <a class="code" href="classNLNET_1_1CServerBufSock.html#o1">_NowReadingBuffer</a>;
00321 
00322         <font class="comment">// Counts the number of bytes read for the current element (length prefix or buffer)</font>
<a name="l00323"></a><a class="code" href="classNLNET_1_1CServerBufSock.html#o2">00323</a>         <a class="code" href="namespaceNLNET.html#a6">TBlockSize</a>                      <a class="code" href="classNLNET_1_1CServerBufSock.html#o2">_BytesRead</a>;
00324 
00325         <font class="comment">// Length of buffer to read</font>
<a name="l00326"></a><a class="code" href="classNLNET_1_1CServerBufSock.html#o3">00326</a>         <a class="code" href="namespaceNLNET.html#a6">TBlockSize</a>                      <a class="code" href="classNLNET_1_1CServerBufSock.html#o3">_Length</a>;
00327 
00328         <font class="comment">// Buffer for nonblocking receives</font>
<a name="l00329"></a><a class="code" href="classNLNET_1_1CServerBufSock.html#o4">00329</a>         std::vector&lt;uint8&gt;      <a class="code" href="classNLNET_1_1CServerBufSock.html#o4">_ReceiveBuffer</a>;
00330 
00331         <font class="comment">// The task that "owns" the CServerBufSock object</font>
<a name="l00332"></a><a class="code" href="classNLNET_1_1CServerBufSock.html#o5">00332</a>         <a class="code" href="classNLNET_1_1CServerBufSock.html#l2">CServerReceiveTask</a>      *<a class="code" href="classNLNET_1_1CServerBufSock.html#o5">_OwnerTask</a>;
00333 
00334 };
00335 
00336 
00337 } <font class="comment">// NLNET</font>
00338 
00339 <font class="preprocessor">#endif // NL_BUF_SOCK_H</font>
00340 <font class="preprocessor"></font>
00341 <font class="comment">/* End of buf_sock.h */</font>
</pre></div>

<!-- footer -->
<BR><FONT Size=+5>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </FONT>
</TD>
<TD WIDTH=15><IMG  SRC=http://www.nevrax.org/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
</TR>
</TABLE>
</BODY>
</HTML>