/usr/share/doc/libucommon-dev/a00189_source.html is in libucommon-doc 3.2.0-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | <!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"/>
<title>UCommon: ucommon/buffer.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.3 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main Page</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Data Structures</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="files.html"><span>File List</span></a></li>
<li><a href="globals.html"><span>Globals</span></a></li>
</ul>
</div>
<h1>ucommon/buffer.h</h1><a href="a00189.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Copyright (C) 2006-2010 David Sugar, Tycho Softworks.</span>
<a name="l00002"></a>00002 <span class="comment">//</span>
<a name="l00003"></a>00003 <span class="comment">// This file is part of GNU uCommon C++.</span>
<a name="l00004"></a>00004 <span class="comment">//</span>
<a name="l00005"></a>00005 <span class="comment">// GNU uCommon C++ is free software: you can redistribute it and/or modify</span>
<a name="l00006"></a>00006 <span class="comment">// it under the terms of the GNU Lesser General Public License as published </span>
<a name="l00007"></a>00007 <span class="comment">// by the Free Software Foundation, either version 3 of the License, or</span>
<a name="l00008"></a>00008 <span class="comment">// (at your option) any later version.</span>
<a name="l00009"></a>00009 <span class="comment">//</span>
<a name="l00010"></a>00010 <span class="comment">// GNU uCommon C++ is distributed in the hope that it will be useful,</span>
<a name="l00011"></a>00011 <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00012"></a>00012 <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00013"></a>00013 <span class="comment">// GNU Lesser General Public License for more details.</span>
<a name="l00014"></a>00014 <span class="comment">//</span>
<a name="l00015"></a>00015 <span class="comment">// You should have received a copy of the GNU Lesser General Public License</span>
<a name="l00016"></a>00016 <span class="comment">// along with GNU uCommon C++. If not, see <http://www.gnu.org/licenses/>.</span>
<a name="l00017"></a>00017
<a name="l00025"></a>00025 <span class="preprocessor">#ifndef _UCOMMON_BUFFER_H_</span>
<a name="l00026"></a>00026 <span class="preprocessor"></span><span class="preprocessor">#define _UCOMMON_BUFFER_H_</span>
<a name="l00027"></a>00027 <span class="preprocessor"></span>
<a name="l00028"></a>00028 <span class="preprocessor">#ifndef _UCOMMON_CONFIG_H_</span>
<a name="l00029"></a>00029 <span class="preprocessor"></span><span class="preprocessor">#include <<a class="code" href="a00201.html" title="Various miscelanous platform specific headers and defines.">ucommon/platform.h</a>></span>
<a name="l00030"></a>00030 <span class="preprocessor">#endif</span>
<a name="l00031"></a>00031 <span class="preprocessor"></span>
<a name="l00032"></a>00032 <span class="preprocessor">#ifndef _UCOMMON_SOCKET_H_</span>
<a name="l00033"></a>00033 <span class="preprocessor"></span><span class="preprocessor">#include <<a class="code" href="a00205.html" title="Common socket class and address manipulation.">ucommon/socket.h</a>></span>
<a name="l00034"></a>00034 <span class="preprocessor">#endif</span>
<a name="l00035"></a>00035 <span class="preprocessor"></span>
<a name="l00036"></a>00036 <span class="preprocessor">#ifndef _UCOMMON_STRING_H_</span>
<a name="l00037"></a>00037 <span class="preprocessor"></span><span class="preprocessor">#include <<a class="code" href="a00207.html" title="A common string class and character string support functions.">ucommon/string.h</a>></span>
<a name="l00038"></a>00038 <span class="preprocessor">#endif</span>
<a name="l00039"></a>00039 <span class="preprocessor"></span>
<a name="l00040"></a>00040 <span class="preprocessor">#ifndef _UCOMMON_FSYS_H_</span>
<a name="l00041"></a>00041 <span class="preprocessor"></span><span class="preprocessor">#include <<a class="code" href="a00193.html" title="Thread-aware file system manipulation class.">ucommon/fsys.h</a>></span>
<a name="l00042"></a>00042 <span class="preprocessor">#endif</span>
<a name="l00043"></a>00043 <span class="preprocessor"></span>
<a name="l00044"></a>00044 NAMESPACE_UCOMMON
<a name="l00045"></a>00045
<a name="l00054"></a><a class="code" href="a00057.html">00054</a> <span class="keyword">class </span>__EXPORT <a class="code" href="a00057.html" title="Common buffered I/O class.">IOBuffer</a>
<a name="l00055"></a>00055 {
<a name="l00056"></a>00056 <span class="keyword">public</span>:
<a name="l00057"></a>00057 <span class="keyword">typedef</span> <span class="keyword">enum</span> {BUF_RD, BUF_WR, BUF_RDWR} type_t;
<a name="l00058"></a>00058
<a name="l00059"></a>00059 <span class="keyword">private</span>:
<a name="l00060"></a>00060 <span class="keyword">const</span> <span class="keywordtype">char</span> *eol;
<a name="l00061"></a>00061 <span class="keywordtype">char</span> *buffer;
<a name="l00062"></a>00062 <span class="keywordtype">char</span> *input, *output;
<a name="l00063"></a>00063 <span class="keywordtype">size_t</span> bufsize, bufpos, insize, outsize;
<a name="l00064"></a>00064 <span class="keywordtype">bool</span> end;
<a name="l00065"></a>00065
<a name="l00066"></a>00066 <span class="keyword">protected</span>:
<a name="l00067"></a>00067 <span class="keywordtype">int</span> ioerror;
<a name="l00068"></a>00068 <a class="code" href="a00201.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout;
<a name="l00069"></a>00069 <span class="keyword">const</span> <span class="keywordtype">char</span> *format;
<a name="l00070"></a>00070
<a name="l00074"></a>00074 <a class="code" href="a00057.html" title="Common buffered I/O class.">IOBuffer</a>();
<a name="l00075"></a>00075
<a name="l00081"></a>00081 <a class="code" href="a00057.html" title="Common buffered I/O class.">IOBuffer</a>(<span class="keywordtype">size_t</span> size, type_t <a class="code" href="a00214.html#ad6378c2aa4e17197d8e936674e5b2687" title="Convenience function to access (lock) shared object through it&#39;s protocol.">access</a> = BUF_RDWR);
<a name="l00082"></a>00082
<a name="l00086"></a>00086 ~<a class="code" href="a00057.html" title="Common buffered I/O class.">IOBuffer</a>();
<a name="l00087"></a>00087
<a name="l00095"></a><a class="code" href="a00057.html#a8eeebeb2b534948cb45dabae7b7eebec">00095</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> seteol(<span class="keyword">const</span> <span class="keywordtype">char</span> *<span class="keywordtype">string</span>)
<a name="l00096"></a>00096 {eol = string;};
<a name="l00097"></a>00097
<a name="l00104"></a>00104 <span class="keywordtype">void</span> allocate(<span class="keywordtype">size_t</span> size, type_t <a class="code" href="a00214.html#ad6378c2aa4e17197d8e936674e5b2687" title="Convenience function to access (lock) shared object through it&#39;s protocol.">access</a> = BUF_RDWR);
<a name="l00105"></a>00105
<a name="l00109"></a>00109 <span class="keywordtype">void</span> <a class="code" href="a00214.html#ab7bef2898e731474a9c3dfa805a6f56d" title="Convenience function to unlock shared object through it&#39;s protocol.">release</a>(<span class="keywordtype">void</span>);
<a name="l00110"></a>00110
<a name="l00118"></a>00118 <span class="keywordtype">char</span> *request(<span class="keywordtype">size_t</span> size);
<a name="l00119"></a>00119
<a name="l00126"></a>00126 <span class="keywordtype">char</span> *gather(<span class="keywordtype">size_t</span> size);
<a name="l00127"></a>00127
<a name="l00135"></a>00135 <span class="keyword">virtual</span> <span class="keywordtype">size_t</span> _push(<span class="keyword">const</span> <span class="keywordtype">char</span> *address, <span class="keywordtype">size_t</span> size);
<a name="l00136"></a>00136
<a name="l00144"></a>00144 <span class="keyword">virtual</span> <span class="keywordtype">size_t</span> _pull(<span class="keywordtype">char</span> *address, <span class="keywordtype">size_t</span> size);
<a name="l00145"></a>00145
<a name="l00151"></a><a class="code" href="a00057.html#aae9e5fdd50a3f75b22f88d5eeafa1b96">00151</a> <span class="keyword">inline</span> <span class="keywordtype">size_t</span> _pending(<span class="keywordtype">void</span>)
<a name="l00152"></a>00152 {<span class="keywordflow">return</span> bufpos;};
<a name="l00153"></a>00153
<a name="l00158"></a><a class="code" href="a00057.html#a4de49cb64116d5f6148bcd33fff89bf2">00158</a> <span class="keyword">inline</span> <span class="keywordtype">size_t</span> _waiting(<span class="keywordtype">void</span>)
<a name="l00159"></a>00159 {<span class="keywordflow">return</span> outsize;};
<a name="l00160"></a>00160
<a name="l00164"></a><a class="code" href="a00057.html#a54ca57f898df1ba47a94292060e9a278">00164</a> <span class="keyword">inline</span> <span class="keywordtype">size_t</span> _buffering(<span class="keywordtype">void</span>)
<a name="l00165"></a>00165 {<span class="keywordflow">return</span> bufsize;};
<a name="l00166"></a>00166
<a name="l00167"></a>00167 <span class="keyword">public</span>:
<a name="l00175"></a>00175 <span class="keywordtype">size_t</span> getstr(<span class="keywordtype">char</span> *address, <span class="keywordtype">size_t</span> count);
<a name="l00176"></a>00176
<a name="l00185"></a>00185 <span class="keywordtype">size_t</span> putstr(<span class="keyword">const</span> <span class="keywordtype">char</span> *address, <span class="keywordtype">size_t</span> count = 0);
<a name="l00186"></a>00186
<a name="l00191"></a>00191 <span class="keywordtype">int</span> getch(<span class="keywordtype">void</span>);
<a name="l00192"></a>00192
<a name="l00197"></a>00197 <span class="keywordtype">int</span> putch(<span class="keywordtype">int</span> ch);
<a name="l00198"></a>00198
<a name="l00203"></a><a class="code" href="a00057.html#a7fa1a785b4b27a70b7bb8b3e741b0579">00203</a> <span class="keyword">inline</span> <span class="keywordtype">size_t</span> writes(<span class="keyword">const</span> <span class="keywordtype">char</span> *<span class="keywordtype">string</span>)
<a name="l00204"></a>00204 {<span class="keywordflow">return</span> putstr(<span class="keywordtype">string</span>);};
<a name="l00205"></a>00205
<a name="l00212"></a><a class="code" href="a00057.html#af678f2b46cfb64414964c49dc5ac2acf">00212</a> <span class="keyword">inline</span> <span class="keywordtype">size_t</span> write(<span class="keyword">const</span> <span class="keywordtype">char</span> *address, <span class="keywordtype">size_t</span> size)
<a name="l00213"></a>00213 {<span class="keywordflow">return</span> putstr(address, size);};
<a name="l00214"></a>00214
<a name="l00221"></a><a class="code" href="a00057.html#ad9ce673f267215a09b40a209e6ed047b">00221</a> <span class="keyword">inline</span> <span class="keywordtype">size_t</span> writeln(<span class="keyword">const</span> <span class="keywordtype">char</span> *<span class="keywordtype">string</span>)
<a name="l00222"></a>00222 {<span class="keywordflow">return</span> putline(<span class="keywordtype">string</span>);};
<a name="l00223"></a>00223
<a name="l00230"></a><a class="code" href="a00057.html#a3193a7d69a22e228845ddf519256d2a1">00230</a> <span class="keyword">inline</span> <span class="keywordtype">size_t</span> write(<a class="code" href="a00157.html" title="A copy-on-write string class that operates by reference count.">String</a>& <span class="keywordtype">string</span>)
<a name="l00231"></a>00231 {<span class="keywordflow">return</span> putline(*<span class="keywordtype">string</span>);};
<a name="l00232"></a>00232
<a name="l00240"></a><a class="code" href="a00057.html#a02985449e23957432bb2ac6ed1433c1b">00240</a> <span class="keyword">inline</span> <span class="keywordtype">size_t</span> readln(<span class="keywordtype">char</span> *address, <span class="keywordtype">size_t</span> size)
<a name="l00241"></a>00241 {<span class="keywordflow">return</span> getline(address, size);};
<a name="l00242"></a>00242
<a name="l00249"></a>00249 <span class="keywordtype">size_t</span> read(<a class="code" href="a00157.html" title="A copy-on-write string class that operates by reference count.">String</a>& <span class="keywordtype">string</span>);
<a name="l00250"></a>00250
<a name="l00257"></a><a class="code" href="a00057.html#a76309b607fd7327aaa1125af0b6c0af5">00257</a> <span class="keyword">inline</span> <span class="keywordtype">size_t</span> read(<span class="keywordtype">char</span> *address, <span class="keywordtype">size_t</span> size)
<a name="l00258"></a>00258 {<span class="keywordflow">return</span> getstr(address, size);};
<a name="l00259"></a>00259
<a name="l00266"></a>00266 <span class="keywordtype">size_t</span> printf(<span class="keyword">const</span> <span class="keywordtype">char</span> *format, ...) __PRINTF(2, 3);
<a name="l00267"></a>00267
<a name="l00272"></a>00272 virtual <span class="keywordtype">bool</span> flush(<span class="keywordtype">void</span>);
<a name="l00273"></a>00273
<a name="l00277"></a>00277 <span class="keywordtype">void</span> purge(<span class="keywordtype">void</span>);
<a name="l00278"></a>00278
<a name="l00282"></a>00282 <span class="keywordtype">void</span> reset(<span class="keywordtype">void</span>);
<a name="l00283"></a>00283
<a name="l00291"></a>00291 <span class="keywordtype">size_t</span> getline(<span class="keywordtype">char</span> *<span class="keywordtype">string</span>, <span class="keywordtype">size_t</span> size);
<a name="l00292"></a>00292
<a name="l00299"></a>00299 <span class="keywordtype">size_t</span> putline(const <span class="keywordtype">char</span> *<span class="keywordtype">string</span>);
<a name="l00300"></a>00300
<a name="l00305"></a>00305 <span class="keywordtype">bool</span> eof();
<a name="l00306"></a>00306
<a name="l00311"></a><a class="code" href="a00057.html#a2de76aed9104fe128c8a753872fc02f8">00311</a> inline <span class="keywordtype">int</span> err(<span class="keywordtype">void</span>)
<a name="l00312"></a>00312 {<span class="keywordflow">return</span> ioerror;};
<a name="l00313"></a>00313
<a name="l00317"></a><a class="code" href="a00057.html#ad95528e45a63ae461eb0674645cd41d7">00317</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> clear(<span class="keywordtype">void</span>)
<a name="l00318"></a>00318 {ioerror = 0;};
<a name="l00319"></a>00319
<a name="l00324"></a><a class="code" href="a00057.html#aede708848660ee8deab7faf9178471f0">00324</a> <span class="keyword">inline</span> operator bool()
<a name="l00325"></a>00325 {<span class="keywordflow">return</span> buffer != NULL;};
<a name="l00326"></a>00326
<a name="l00331"></a><a class="code" href="a00057.html#a6326bc08726bc9b8e777cfff32b35194">00331</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator!()
<a name="l00332"></a>00332 {<span class="keywordflow">return</span> buffer == NULL;};
<a name="l00333"></a>00333
<a name="l00338"></a><a class="code" href="a00057.html#a1e964d175adae6bb13b9f79611fa081b">00338</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> isopen(<span class="keywordtype">void</span>)
<a name="l00339"></a>00339 {<span class="keywordflow">return</span> buffer != NULL;};
<a name="l00340"></a>00340
<a name="l00345"></a><a class="code" href="a00057.html#a953213c59a9d4cd28252d3f91ce89182">00345</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> isinput(<span class="keywordtype">void</span>)
<a name="l00346"></a>00346 {<span class="keywordflow">return</span> input != NULL;};
<a name="l00347"></a>00347
<a name="l00352"></a><a class="code" href="a00057.html#a0cdbc447b10f0e190f1821bf9b0b0a8e">00352</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> isoutput(<span class="keywordtype">void</span>)
<a name="l00353"></a>00353 {<span class="keywordflow">return</span> output != NULL;};
<a name="l00354"></a>00354
<a name="l00358"></a><a class="code" href="a00057.html#a72084f8f3993b26aa0e16fe347aeb545">00358</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> seteof(<span class="keywordtype">void</span>)
<a name="l00359"></a>00359 {end = <span class="keyword">true</span>;};
<a name="l00360"></a>00360
<a name="l00365"></a>00365 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> pending(<span class="keywordtype">void</span>);
<a name="l00366"></a>00366 };
<a name="l00367"></a>00367
<a name="l00374"></a><a class="code" href="a00054.html">00374</a> <span class="keyword">class </span><a class="code" href="a00054.html" title="A generic file streaming class built from the I/O buffer.">fbuf</a> : <span class="keyword">public</span> <a class="code" href="a00057.html" title="Common buffered I/O class.">IOBuffer</a>, <span class="keyword">private</span> <a class="code" href="a00056.html" title="A container for generic and o/s portable threadsafe file system functions.">fsys</a>
<a name="l00375"></a>00375 {
<a name="l00376"></a>00376 <span class="keyword">private</span>:
<a name="l00377"></a>00377 offset_t inpos, outpos;
<a name="l00378"></a>00378
<a name="l00379"></a>00379 <span class="keyword">protected</span>:
<a name="l00380"></a>00380 <span class="keywordtype">size_t</span> _push(<span class="keyword">const</span> <span class="keywordtype">char</span> *address, <span class="keywordtype">size_t</span> size);
<a name="l00381"></a>00381 <span class="keywordtype">size_t</span> _pull(<span class="keywordtype">char</span> *address, <span class="keywordtype">size_t</span> size);
<a name="l00382"></a>00382
<a name="l00383"></a>00383 <span class="keyword">inline</span> fd_t getfile(<span class="keywordtype">void</span>)
<a name="l00384"></a>00384 {<span class="keywordflow">return</span> fd;};
<a name="l00385"></a>00385
<a name="l00386"></a>00386 <span class="keyword">public</span>:
<a name="l00390"></a>00390 <a class="code" href="a00054.html" title="A generic file streaming class built from the I/O buffer.">fbuf</a>();
<a name="l00391"></a>00391
<a name="l00395"></a>00395 ~<a class="code" href="a00054.html" title="A generic file streaming class built from the I/O buffer.">fbuf</a>();
<a name="l00396"></a>00396
<a name="l00404"></a>00404 <a class="code" href="a00054.html" title="A generic file streaming class built from the I/O buffer.">fbuf</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *path, <a class="code" href="a00056.html#a5e886a4f005b2a2948d2a3fb4e9f0deb" title="Enumerated file access modes.">fsys::access_t</a> <a class="code" href="a00214.html#ad6378c2aa4e17197d8e936674e5b2687" title="Convenience function to access (lock) shared object through it&#39;s protocol.">access</a>, <span class="keywordtype">unsigned</span> permissions, <span class="keywordtype">size_t</span> size);
<a name="l00405"></a>00405
<a name="l00412"></a>00412 <a class="code" href="a00054.html" title="A generic file streaming class built from the I/O buffer.">fbuf</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *path, <a class="code" href="a00056.html#a5e886a4f005b2a2948d2a3fb4e9f0deb" title="Enumerated file access modes.">fsys::access_t</a> access, <span class="keywordtype">size_t</span> size);
<a name="l00413"></a>00413
<a name="l00422"></a>00422 <span class="keywordtype">void</span> create(<span class="keyword">const</span> <span class="keywordtype">char</span> *path, <a class="code" href="a00056.html#a5e886a4f005b2a2948d2a3fb4e9f0deb" title="Enumerated file access modes.">fsys::access_t</a> access = fsys::ACCESS_APPEND, <span class="keywordtype">unsigned</span> permissions = 0640, <span class="keywordtype">size_t</span> size = 512);
<a name="l00423"></a>00423
<a name="l00430"></a>00430 <span class="keywordtype">void</span> open(<span class="keyword">const</span> <span class="keywordtype">char</span> *path, <a class="code" href="a00056.html#a5e886a4f005b2a2948d2a3fb4e9f0deb" title="Enumerated file access modes.">fsys::access_t</a> access = fsys::ACCESS_RDWR, <span class="keywordtype">size_t</span> size = 512);
<a name="l00431"></a>00431
<a name="l00435"></a>00435 <span class="keywordtype">void</span> close(<span class="keywordtype">void</span>);
<a name="l00436"></a>00436
<a name="l00444"></a>00444 <span class="keywordtype">bool</span> seek(offset_t offset);
<a name="l00445"></a>00445
<a name="l00452"></a>00452 <span class="keywordtype">bool</span> trunc(offset_t offset);
<a name="l00453"></a>00453
<a name="l00460"></a>00460 offset_t tell(<span class="keywordtype">void</span>);
<a name="l00461"></a>00461 };
<a name="l00462"></a>00462
<a name="l00468"></a><a class="code" href="a00161.html">00468</a> <span class="keyword">class </span>__EXPORT <a class="code" href="a00161.html" title="A generic tcp server class for TCPSocket.">TCPServer</a> : <span class="keyword">public</span> <a class="code" href="a00070.html" title="A bound socket used to listen for inbound socket connections.">ListenSocket</a>
<a name="l00469"></a>00469 {
<a name="l00470"></a>00470 <span class="keyword">private</span>:
<a name="l00471"></a>00471 <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="a00162.html" title="A generic tcp socket class that offers i/o buffering.">TCPSocket</a>;
<a name="l00472"></a>00472
<a name="l00473"></a>00473 <span class="keyword">const</span> <span class="keywordtype">char</span> *servicetag;
<a name="l00474"></a>00474
<a name="l00475"></a>00475 <span class="keyword">public</span>:
<a name="l00484"></a>00484 <a class="code" href="a00161.html" title="A generic tcp server class for TCPSocket.">TCPServer</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *service, <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="a00152.html" title="A generic socket address class.">address</a> = <span class="stringliteral">"*"</span>, <span class="keywordtype">unsigned</span> backlog = 5, <span class="keywordtype">int</span> protocol = 0);
<a name="l00485"></a>00485 };
<a name="l00486"></a>00486
<a name="l00493"></a><a class="code" href="a00162.html">00493</a> <span class="keyword">class </span>__EXPORT <a class="code" href="a00162.html" title="A generic tcp socket class that offers i/o buffering.">TCPSocket</a> : <span class="keyword">public</span> <a class="code" href="a00057.html" title="Common buffered I/O class.">IOBuffer</a>, <span class="keyword">protected</span> <a class="code" href="a00151.html" title="A generic socket base class.">Socket</a>
<a name="l00494"></a>00494 {
<a name="l00495"></a>00495 <span class="keyword">private</span>:
<a name="l00496"></a>00496 <span class="keywordtype">void</span> _buffer(<span class="keywordtype">size_t</span> size);
<a name="l00497"></a>00497
<a name="l00498"></a>00498 <span class="keywordtype">char</span> serviceid[16];
<a name="l00499"></a>00499 <span class="keyword">const</span> <span class="keywordtype">char</span> *servicetag;
<a name="l00500"></a>00500
<a name="l00501"></a>00501 <span class="keyword">protected</span>:
<a name="l00502"></a>00502 <span class="keyword">virtual</span> <span class="keywordtype">size_t</span> <a class="code" href="a00057.html#abe10b39c40a9cc0ba70b9e025dec072a" title="Method to push buffer into physical i/o (write).">_push</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="a00152.html" title="A generic socket address class.">address</a>, <span class="keywordtype">size_t</span> size);
<a name="l00503"></a>00503 <span class="keyword">virtual</span> <span class="keywordtype">size_t</span> <a class="code" href="a00057.html#ad6089d06f36137661b2f0c37943a4187" title="Method to pull buffer from physical i/o (read).">_pull</a>(<span class="keywordtype">char</span> *address, <span class="keywordtype">size_t</span> size);
<a name="l00504"></a>00504
<a name="l00509"></a><a class="code" href="a00162.html#a427d117adcc383bb0d527f200335e5a3">00509</a> <span class="keyword">inline</span> socket_t getsocket(<span class="keywordtype">void</span>)<span class="keyword"> const</span>
<a name="l00510"></a>00510 <span class="keyword"> </span>{<span class="keywordflow">return</span> so;};
<a name="l00511"></a>00511
<a name="l00520"></a><a class="code" href="a00162.html#a564b9472822fc844374afa6fe2896e8d">00520</a> <span class="keyword">inline</span> <span class="keywordtype">short</span> <a class="code" href="a00151.html#ac133118ede1b69563c0b74e88a0db754" title="Get the service port of a socket.">getservice</a>(<span class="keywordtype">void</span>)<span class="keyword"> const</span>
<a name="l00521"></a>00521 <span class="keyword"> </span>{<span class="keywordflow">return</span> (<span class="keywordtype">short</span>)(atol(serviceid));};
<a name="l00522"></a>00522
<a name="l00527"></a><a class="code" href="a00162.html#a52172dafbeda0cb51e7624f5ae3611e7">00527</a> <span class="keyword">inline</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *tag(<span class="keywordtype">void</span>)<span class="keyword"> const</span>
<a name="l00528"></a>00528 <span class="keyword"> </span>{<span class="keywordflow">return</span> servicetag;};
<a name="l00529"></a>00529
<a name="l00538"></a>00538 <span class="keywordtype">size_t</span> <a class="code" href="a00151.html#a3dec81eb262e35f7a0ff633d64e93881" title="Peek at data waiting in the socket receive buffer.">peek</a>(<span class="keywordtype">char</span> *data, <span class="keywordtype">size_t</span> size, <a class="code" href="a00201.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout = Timer::inf);
<a name="l00539"></a>00539
<a name="l00540"></a>00540 <span class="keyword">public</span>:
<a name="l00545"></a>00545 <a class="code" href="a00162.html" title="A generic tcp socket class that offers i/o buffering.">TCPSocket</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *service);
<a name="l00546"></a>00546
<a name="l00552"></a>00552 <a class="code" href="a00162.html" title="A generic tcp socket class that offers i/o buffering.">TCPSocket</a>(<a class="code" href="a00161.html" title="A generic tcp server class for TCPSocket.">TCPServer</a> *server, <span class="keywordtype">size_t</span> size = 536);
<a name="l00553"></a>00553
<a name="l00560"></a>00560 <a class="code" href="a00162.html" title="A generic tcp socket class that offers i/o buffering.">TCPSocket</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *service, <span class="keyword">const</span> <span class="keywordtype">char</span> *host, <span class="keywordtype">size_t</span> size = 536);
<a name="l00561"></a>00561
<a name="l00565"></a>00565 <span class="keyword">virtual</span> ~<a class="code" href="a00162.html" title="A generic tcp socket class that offers i/o buffering.">TCPSocket</a>();
<a name="l00566"></a>00566
<a name="l00573"></a>00573 <span class="keywordtype">void</span> <a class="code" href="a00151.html#add139034e67c0f56be9bbffc58a67698" title="Convert socket into FILE handle for reading.">open</a>(<a class="code" href="a00161.html" title="A generic tcp server class for TCPSocket.">TCPServer</a> *server, <span class="keywordtype">size_t</span> size = 536);
<a name="l00574"></a>00574
<a name="l00581"></a>00581 <span class="keywordtype">void</span> <a class="code" href="a00151.html#add139034e67c0f56be9bbffc58a67698" title="Convert socket into FILE handle for reading.">open</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *host, <span class="keywordtype">size_t</span> size = 536);
<a name="l00582"></a>00582
<a name="l00586"></a>00586 <span class="keywordtype">void</span> <a class="code" href="a00151.html#a1d52e9bdeb4139685665f4b6effa671f" title="Cleanly close a connected socket descriptor mapped to a file handle.">close</a>(<span class="keywordtype">void</span>);
<a name="l00587"></a>00587
<a name="l00592"></a>00592 <span class="keywordtype">void</span> <a class="code" href="a00151.html#a2959b9856257634f27857d896e753160" title="Set socket blocking I/O mode.">blocking</a>(<a class="code" href="a00201.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout = Timer::inf);
<a name="l00593"></a>00593
<a name="l00598"></a>00598 <span class="keywordtype">bool</span> <a class="code" href="a00057.html#af74ba2a42576801ceaab76eee3fbef66" title="See if data is pending.">pending</a>(<span class="keywordtype">void</span>);
<a name="l00599"></a>00599 };
<a name="l00600"></a>00600
<a name="l00604"></a><a class="code" href="a00214.html#ab4d17d1c905afc6abf693d6f8bfa34ca">00604</a> <span class="keyword">typedef</span> <a class="code" href="a00054.html" title="A generic file streaming class built from the I/O buffer.">fbuf</a> <a class="code" href="a00054.html" title="A generic file streaming class built from the I/O buffer.">file_t</a>;
<a name="l00605"></a>00605
<a name="l00609"></a><a class="code" href="a00214.html#a5d66ea32f33f3825ebf7785eed351ef6">00609</a> <span class="keyword">typedef</span> <a class="code" href="a00162.html" title="A generic tcp socket class that offers i/o buffering.">TCPSocket</a> <a class="code" href="a00162.html" title="A generic tcp socket class that offers i/o buffering.">tcp_t</a>;
<a name="l00610"></a>00610
<a name="l00611"></a>00611 END_NAMESPACE
<a name="l00612"></a>00612
<a name="l00613"></a>00613 <span class="preprocessor">#endif</span>
</pre></div></div>
<hr class="footer"/><address style="text-align: right;"><small>Generated on Tue Jul 6 08:22:01 2010 for UCommon by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
</body>
</html>
|