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 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- q3socketdevice.cpp -->
<title>Qt 4.8: Q3SocketDevice Class Reference</title>
<link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
<div class="content">
<a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
</div>
<div class="breadcrumb toolblock">
<ul>
<li class="first"><a href="index.html">Home</a></li>
<!-- Breadcrumbs go here -->
<li><a href="modules.html">Modules</a></li>
<li><a href="qt3support.html">Qt3Support</a></li>
<li>Q3SocketDevice</li>
</ul>
</div>
</div>
<div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-types">Public Types</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#protected-functions">Protected Functions</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<h1 class="title">Q3SocketDevice Class Reference</h1>
<!-- $$$Q3SocketDevice-brief -->
<p>The Q3SocketDevice class provides a platform-independent low-level socket API. <a href="#details">More...</a></p>
<!-- @@@Q3SocketDevice -->
<pre class="cpp"> <span class="preprocessor">#include <Q3SocketDevice></span></pre><p><b>This class is part of the Qt 3 support library.</b> It is provided to keep old source code working. We strongly advise against using it in new code. See <a href="porting4.html#qsocketdevice">Porting to Qt 4</a> for more information.</p>
<p><b>Inherits: </b><a href="qiodevice.html">QIODevice</a>.</p>
<p><b>Note:</b> All functions in this class are <a href="threads-reentrancy.html#reentrant">reentrant</a>.</p>
<ul>
<li><a href="q3socketdevice-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-types"></a>
<h2>Public Types</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#Error-enum">Error</a></b> { NoError, AlreadyBound, Inaccessible, NoResources, ..., UnknownError }</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#Protocol-enum">Protocol</a></b> { IPv4, IPv6, Unknown }</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#Type-enum">Type</a></b> { Stream, Datagram }</td></tr>
</table>
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#Q3SocketDevice">Q3SocketDevice</a></b> ( Type <i>type</i> = Stream )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#Q3SocketDevice-2">Q3SocketDevice</a></b> ( Type <i>type</i>, Protocol <i>protocol</i>, int <i>dummy</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#Q3SocketDevice-3">Q3SocketDevice</a></b> ( int <i>socket</i>, Type <i>type</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#dtor.Q3SocketDevice">~Q3SocketDevice</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual int </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#accept">accept</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QHostAddress </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#address">address</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#addressReusable">addressReusable</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Offset </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#at">at</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#at-2">at</a></b> ( Offset <i>offset</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#bind">bind</a></b> ( const QHostAddress & <i>address</i>, Q_UINT16 <i>port</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#blocking">blocking</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#connect">connect</a></b> ( const QHostAddress & <i>addr</i>, Q_UINT16 <i>port</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Error </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#error">error</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#flush">flush</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#isValid">isValid</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#listen">listen</a></b> ( int <i>backlog</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#open-2">open</a></b> ( int <i>mode</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QHostAddress </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#peerAddress">peerAddress</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Q_UINT16 </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#peerPort">peerPort</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Q_UINT16 </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#port">port</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Protocol </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#protocol">protocol</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qint64 </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#readBlock">readBlock</a></b> ( char * <i>data</i>, Q_ULONG <i>maxlen</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#receiveBufferSize">receiveBufferSize</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#sendBufferSize">sendBufferSize</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#setAddressReusable">setAddressReusable</a></b> ( bool <i>enable</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#setBlocking">setBlocking</a></b> ( bool <i>enable</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#setReceiveBufferSize">setReceiveBufferSize</a></b> ( uint <i>size</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#setSendBufferSize">setSendBufferSize</a></b> ( uint <i>size</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#setSocket">setSocket</a></b> ( int <i>socket</i>, Type <i>type</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#socket">socket</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Type </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#type">type</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Q_LONG </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#waitForMore">waitForMore</a></b> ( int <i>msecs</i>, bool * <i>timeout</i> = 0 ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Q_LONG </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#writeBlock">writeBlock</a></b> ( const char * <i>data</i>, Q_ULONG <i>len</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual Q_LONG </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#writeBlock-2">writeBlock</a></b> ( const char * <i>data</i>, Q_ULONG <i>len</i>, const QHostAddress & <i>host</i>, Q_UINT16 <i>port</i> )</td></tr>
</table>
<a name="reimplemented-public-functions"></a>
<h2>Reimplemented Public Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#atEnd">atEnd</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual qint64 </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#bytesAvailable">bytesAvailable</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#close">close</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#open">open</a></b> ( OpenMode <i>mode</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual Offset </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#size">size</a></b> () const</td></tr>
</table>
<ul>
<li class="fn">33 public functions inherited from <a href="qiodevice.html#public-functions">QIODevice</a></li>
<li class="fn">29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
</ul>
<a name="protected-functions"></a>
<h2>Protected Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#setError">setError</a></b> ( Error <i>err</i> )</td></tr>
</table>
<a name="reimplemented-protected-functions"></a>
<h2>Reimplemented Protected Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual qint64 </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#readData">readData</a></b> ( char * <i>data</i>, qint64 <i>maxlen</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual qint64 </td><td class="memItemRight bottomAlign"><b><a href="q3socketdevice.html#writeData">writeData</a></b> ( const char * <i>data</i>, qint64 <i>len</i> )</td></tr>
</table>
<ul>
<li class="fn">5 protected functions inherited from <a href="qiodevice.html#protected-functions">QIODevice</a></li>
<li class="fn">8 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li class="fn">1 property inherited from <a href="qobject.html#properties">QObject</a></li>
<li class="fn">1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
<li class="fn">4 signals inherited from <a href="qiodevice.html#signals">QIODevice</a></li>
<li class="fn">1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
<li class="fn">7 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
</ul>
<a name="details"></a>
<!-- $$$Q3SocketDevice-description -->
<div class="descr">
<h2>Detailed Description</h2>
<p>The Q3SocketDevice class provides a platform-independent low-level socket API.</p>
<p>This class provides a low level API for working with sockets. Users of this class are assumed to have networking experience. For most users the <a href="q3socket.html">Q3Socket</a> class provides a much easier and high level alternative, but certain things (like UDP) can't be done with <a href="q3socket.html">Q3Socket</a> and if you need a platform-independent API for those, Q3SocketDevice is the right choice.</p>
<p>The essential purpose of the class is to provide a <a href="qiodevice.html">QIODevice</a> that works on sockets, wrapped in a platform-independent API.</p>
<p>When calling <a href="q3socketdevice.html#connect">connect</a>() or <a href="q3socketdevice.html#bind">bind</a>(), Q3SocketDevice detects the protocol family (IPv4, IPv6) automatically. Passing the protocol family to Q3SocketDevice's constructor or to <a href="q3socketdevice.html#setSocket">setSocket</a>() forces creation of a socket device of a specific protocol. If not set, the protocol will be detected at the first call to <a href="q3socketdevice.html#connect">connect</a>() or <a href="q3socketdevice.html#bind">bind</a>().</p>
</div>
<p><b>See also </b><a href="q3socket.html">Q3Socket</a>, <a href="qsocketnotifier.html">QSocketNotifier</a>, and <a href="qhostaddress.html">QHostAddress</a>.</p>
<!-- @@@Q3SocketDevice -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$Error$$$NoError$$$AlreadyBound$$$Inaccessible$$$NoResources$$$InternalError$$$Bug$$$Impossible$$$NoFiles$$$ConnectionRefused$$$NetworkFailure$$$UnknownError -->
<h3 class="fn"><a name="Error-enum"></a>enum Q3SocketDevice::<span class="name">Error</span></h3>
<p>This enum type describes the error states of <a href="q3socketdevice.html" class="compat">Q3SocketDevice</a>.</p>
<table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><tt>Q3SocketDevice::NoError</tt></td><td class="topAlign"><tt>0</tt></td><td class="topAlign">No error has occurred.</td></tr>
<tr><td class="topAlign"><tt>Q3SocketDevice::AlreadyBound</tt></td><td class="topAlign"><tt>1</tt></td><td class="topAlign">The device is already bound, according to <a href="q3socketdevice.html#bind">bind</a>().</td></tr>
<tr><td class="topAlign"><tt>Q3SocketDevice::Inaccessible</tt></td><td class="topAlign"><tt>2</tt></td><td class="topAlign">The operating system or firewall prohibited the action.</td></tr>
<tr><td class="topAlign"><tt>Q3SocketDevice::NoResources</tt></td><td class="topAlign"><tt>3</tt></td><td class="topAlign">The operating system ran out of a resource.</td></tr>
<tr><td class="topAlign"><tt>Q3SocketDevice::InternalError</tt></td><td class="topAlign"><tt>4</tt></td><td class="topAlign">An internal error occurred in <a href="q3socketdevice.html" class="compat">Q3SocketDevice</a>.</td></tr>
<tr><td class="topAlign"><tt>Q3SocketDevice::Impossible</tt></td><td class="topAlign">?</td><td class="topAlign">An attempt was made to do something which makes no sense. For example:<pre class="cpp"> <span class="operator">::</span><a href="q3socketdevice.html#close">close</a>( sd<span class="operator">-</span><span class="operator">></span>socket() );
sd<span class="operator">-</span><span class="operator">></span><a href="q3socketdevice.html#writeBlock">writeBlock</a>( someData<span class="operator">,</span> <span class="number">42</span> );</pre>
</td></tr>
</table>
<p>The libc ::close() closes the socket, but <a href="q3socketdevice.html" class="compat">Q3SocketDevice</a> is not aware of this. So when you call <a href="q3socketdevice.html#writeBlock">writeBlock</a>(), the impossible happens.</p>
<table class="valuelist"><tr valign="top" class="even"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><tt>Q3SocketDevice::NoFiles</tt></td><td class="topAlign">?</td><td class="topAlign">The operating system will not let <a href="q3socketdevice.html" class="compat">Q3SocketDevice</a> open another file.</td></tr>
<tr><td class="topAlign"><tt>Q3SocketDevice::ConnectionRefused</tt></td><td class="topAlign">?</td><td class="topAlign">A connection attempt was rejected by the peer.</td></tr>
<tr><td class="topAlign"><tt>Q3SocketDevice::NetworkFailure</tt></td><td class="topAlign">?</td><td class="topAlign">There is a network failure.</td></tr>
<tr><td class="topAlign"><tt>Q3SocketDevice::UnknownError</tt></td><td class="topAlign">?</td><td class="topAlign">The operating system did something unexpected.</td></tr>
</table>
<!-- @@@Error -->
<!-- $$$Protocol$$$IPv4$$$IPv6$$$Unknown -->
<h3 class="fn"><a name="Protocol-enum"></a>enum Q3SocketDevice::<span class="name">Protocol</span></h3>
<p>This enum type describes the protocol family of the socket. Possible values are:</p>
<table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><tt>Q3SocketDevice::IPv4</tt></td><td class="topAlign"><tt>0</tt></td><td class="topAlign">The socket is an IPv4 socket.</td></tr>
<tr><td class="topAlign"><tt>Q3SocketDevice::IPv6</tt></td><td class="topAlign"><tt>1</tt></td><td class="topAlign">The socket is an IPv6 socket.</td></tr>
<tr><td class="topAlign"><tt>Q3SocketDevice::Unknown</tt></td><td class="topAlign"><tt>2</tt></td><td class="topAlign">The protocol family of the socket is not known. This can happen if you use <a href="q3socketdevice.html" class="compat">Q3SocketDevice</a> with an already existing socket; it tries to determine the protocol family, but this can fail if the protocol family is not known to <a href="q3socketdevice.html" class="compat">Q3SocketDevice</a>.</td></tr>
</table>
<p><b>See also </b><a href="q3socketdevice.html#protocol">protocol</a>() and <a href="q3socketdevice.html#setSocket">setSocket</a>().</p>
<!-- @@@Protocol -->
<!-- $$$Type$$$Stream$$$Datagram -->
<h3 class="fn"><a name="Type-enum"></a>enum Q3SocketDevice::<span class="name">Type</span></h3>
<p>This enum type describes the type of the socket:</p>
<table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><tt>Q3SocketDevice::Stream</tt></td><td class="topAlign"><tt>0</tt></td><td class="topAlign">a stream socket (TCP, usually)</td></tr>
<tr><td class="topAlign"><tt>Q3SocketDevice::Datagram</tt></td><td class="topAlign"><tt>1</tt></td><td class="topAlign">a datagram socket (UDP, usually)</td></tr>
</table>
<!-- @@@Type -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$Q3SocketDevice[overload1]$$$Q3SocketDeviceType -->
<h3 class="fn"><a name="Q3SocketDevice"></a>Q3SocketDevice::<span class="name">Q3SocketDevice</span> ( <span class="type"><a href="q3socketdevice.html#Type-enum">Type</a></span> <i>type</i> = Stream )</h3>
<p>Creates a <a href="q3socketdevice.html" class="compat">Q3SocketDevice</a> object for a stream or datagram socket.</p>
<p>The <i>type</i> argument must be either <a href="q3socketdevice.html#Type-enum">Q3SocketDevice::Stream</a> for a reliable, connection-oriented TCP socket, or <tt>Q3SocketDevice::Datagram</tt> for an unreliable UDP socket.</p>
<p>The socket is created as an IPv4 socket.</p>
<p><b>See also </b><a href="q3socketdevice.html#blocking">blocking</a>() and <a href="q3socketdevice.html#protocol">protocol</a>().</p>
<!-- @@@Q3SocketDevice -->
<!-- $$$Q3SocketDevice$$$Q3SocketDeviceTypeProtocolint -->
<h3 class="fn"><a name="Q3SocketDevice-2"></a>Q3SocketDevice::<span class="name">Q3SocketDevice</span> ( <span class="type"><a href="q3socketdevice.html#Type-enum">Type</a></span> <i>type</i>, <span class="type"><a href="q3socketdevice.html#Protocol-enum">Protocol</a></span> <i>protocol</i>, <span class="type">int</span> <i>dummy</i> )</h3>
<p>Creates a <a href="q3socketdevice.html" class="compat">Q3SocketDevice</a> object for a stream or datagram socket.</p>
<p>The <i>type</i> argument must be either <a href="q3socketdevice.html#Type-enum">Q3SocketDevice::Stream</a> for a reliable, connection-oriented TCP socket, or <tt>Q3SocketDevice::Datagram</tt> for an unreliable UDP socket.</p>
<p>The <i>protocol</i> indicates whether the socket should be of type IPv4 or IPv6. Passing <tt>Unknown</tt> is not meaningful in this context and you should avoid using (it creates an IPv4 socket, but your code is not easily readable).</p>
<p>The argument <i>dummy</i> is necessary for compatibility with some compilers.</p>
<p><b>See also </b><a href="q3socketdevice.html#blocking">blocking</a>() and <a href="q3socketdevice.html#protocol">protocol</a>().</p>
<!-- @@@Q3SocketDevice -->
<!-- $$$Q3SocketDevice$$$Q3SocketDeviceintType -->
<h3 class="fn"><a name="Q3SocketDevice-3"></a>Q3SocketDevice::<span class="name">Q3SocketDevice</span> ( <span class="type">int</span> <i>socket</i>, <span class="type"><a href="q3socketdevice.html#Type-enum">Type</a></span> <i>type</i> )</h3>
<p>Creates a <a href="q3socketdevice.html" class="compat">Q3SocketDevice</a> object for the existing socket <i>socket</i>.</p>
<p>The <i>type</i> argument must match the actual socket type; use <tt>Q3SocketDevice::Stream</tt> for a reliable, connection-oriented TCP socket, or <a href="q3socketdevice.html#Type-enum">Q3SocketDevice::Datagram</a> for an unreliable, connectionless UDP socket.</p>
<!-- @@@Q3SocketDevice -->
<!-- $$$~Q3SocketDevice[overload1]$$$~Q3SocketDevice -->
<h3 class="fn"><a name="dtor.Q3SocketDevice"></a>Q3SocketDevice::<span class="name">~Q3SocketDevice</span> ()<tt> [virtual]</tt></h3>
<p>Destroys the socket device and closes the socket if it is open.</p>
<!-- @@@~Q3SocketDevice -->
<!-- $$$accept[overload1]$$$accept -->
<h3 class="fn"><a name="accept"></a><span class="type">int</span> Q3SocketDevice::<span class="name">accept</span> ()<tt> [virtual]</tt></h3>
<p>Extracts the first connection from the queue of pending connections for this socket and returns a new socket identifier. Returns -1 if the operation failed.</p>
<p><b>See also </b><a href="q3socketdevice.html#bind">bind</a>() and <a href="q3socketdevice.html#listen">listen</a>().</p>
<!-- @@@accept -->
<!-- $$$address[overload1]$$$address -->
<h3 class="fn"><a name="address"></a><span class="type"><a href="qhostaddress.html">QHostAddress</a></span> Q3SocketDevice::<span class="name">address</span> () const</h3>
<p>Returns the address of this socket device. This may be 0.0.0.0 for a while, but is set to something sensible as soon as a sensible value is available.</p>
<!-- @@@address -->
<!-- $$$addressReusable[overload1]$$$addressReusable -->
<h3 class="fn"><a name="addressReusable"></a><span class="type">bool</span> Q3SocketDevice::<span class="name">addressReusable</span> () const</h3>
<p>Returns true if the address of this socket can be used by other sockets at the same time, and false if this socket claims exclusive ownership.</p>
<p><b>See also </b><a href="q3socketdevice.html#setAddressReusable">setAddressReusable</a>().</p>
<!-- @@@addressReusable -->
<!-- $$$at[overload1]$$$at -->
<h3 class="fn"><a name="at"></a><span class="type"><a href="qiodevice-qt3.html#Offset-typedef">Offset</a></span> Q3SocketDevice::<span class="name">at</span> () const</h3>
<p>The read/write index is meaningless for a socket, therefore this function returns 0.</p>
<!-- @@@at -->
<!-- $$$at$$$atOffset -->
<h3 class="fn"><a name="at-2"></a><span class="type">bool</span> Q3SocketDevice::<span class="name">at</span> ( <span class="type"><a href="qiodevice-qt3.html#Offset-typedef">Offset</a></span> <i>offset</i> )</h3>
<p>The read/write index is meaningless for a socket, therefore this function does nothing and returns true.</p>
<p>The <i>offset</i> parameter is ignored.</p>
<!-- @@@at -->
<!-- $$$atEnd[overload1]$$$atEnd -->
<h3 class="fn"><a name="atEnd"></a><span class="type">bool</span> Q3SocketDevice::<span class="name">atEnd</span> () const<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qiodevice.html#atEnd">QIODevice::atEnd</a>().</p>
<p>Returns true if no data is currently available at the socket; otherwise returns false.</p>
<!-- @@@atEnd -->
<!-- $$$bind[overload1]$$$bindconstQHostAddress&Q_UINT16 -->
<h3 class="fn"><a name="bind"></a><span class="type">bool</span> Q3SocketDevice::<span class="name">bind</span> ( const <span class="type"><a href="qhostaddress.html">QHostAddress</a></span> & <i>address</i>, <span class="type"><a href="qtglobal-qt3.html#Q_UINT16-typedef">Q_UINT16</a></span> <i>port</i> )<tt> [virtual]</tt></h3>
<p>Assigns a name to an unnamed socket. The name is the host address <i>address</i> and the port number <i>port</i>. If the operation succeeds, bind() returns true; otherwise it returns false without changing what <a href="q3socketdevice.html#port">port</a>() and <a href="q3socketdevice.html#address">address</a>() return.</p>
<p>bind() is used by servers for setting up incoming connections. Call bind() before <a href="q3socketdevice.html#listen">listen</a>().</p>
<!-- @@@bind -->
<!-- $$$blocking[overload1]$$$blocking -->
<h3 class="fn"><a name="blocking"></a><span class="type">bool</span> Q3SocketDevice::<span class="name">blocking</span> () const</h3>
<p>Returns true if the socket is valid and in blocking mode; otherwise returns false.</p>
<p>Note that this function does not set <a href="q3socketdevice.html#error">error</a>().</p>
<p><b>Warning:</b> On Windows, this function always returns true since the ioctlsocket() function is broken.</p>
<p><b>See also </b><a href="q3socketdevice.html#setBlocking">setBlocking</a>() and <a href="q3socketdevice.html#isValid">isValid</a>().</p>
<!-- @@@blocking -->
<!-- $$$bytesAvailable[overload1]$$$bytesAvailable -->
<h3 class="fn"><a name="bytesAvailable"></a><span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> Q3SocketDevice::<span class="name">bytesAvailable</span> () const<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qiodevice.html#bytesAvailable">QIODevice::bytesAvailable</a>().</p>
<p>Returns the number of bytes available for reading, or -1 if an error occurred.</p>
<p><b>Warning:</b> On Microsoft Windows, we use the ioctlsocket() function to determine the number of bytes queued on the socket. According to Microsoft (KB Q125486), ioctlsocket() sometimes returns an incorrect number. The only safe way to determine the amount of data on the socket is to read it using <a href="q3socketdevice.html#readBlock">readBlock</a>(). <a href="porting4.html#qsocket">QSocket</a> has workarounds to deal with this problem.</p>
<!-- @@@bytesAvailable -->
<!-- $$$close[overload1]$$$close -->
<h3 class="fn"><a name="close"></a><span class="type">void</span> Q3SocketDevice::<span class="name">close</span> ()<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qiodevice.html#close">QIODevice::close</a>().</p>
<p>Closes the socket and sets the socket identifier to -1 (invalid).</p>
<p>(This function ignores errors; if there are any then a file descriptor leakage might result. As far as we know, the only error that can arise is EBADF, and that would of course not cause leakage. There may be OS-specific errors that we haven't come across, however.)</p>
<p><b>See also </b><a href="q3socketdevice.html#open">open</a>().</p>
<!-- @@@close -->
<!-- $$$connect[overload1]$$$connectconstQHostAddress&Q_UINT16 -->
<h3 class="fn"><a name="connect"></a><span class="type">bool</span> Q3SocketDevice::<span class="name">connect</span> ( const <span class="type"><a href="qhostaddress.html">QHostAddress</a></span> & <i>addr</i>, <span class="type"><a href="qtglobal-qt3.html#Q_UINT16-typedef">Q_UINT16</a></span> <i>port</i> )<tt> [virtual]</tt></h3>
<p>Connects to the IP address and port specified by <i>addr</i> and <i>port</i>. Returns true if it establishes a connection; otherwise returns false. If it returns false, <a href="q3socketdevice.html#error">error</a>() explains why.</p>
<p>Note that <a href="q3socketdevice.html#error">error</a>() commonly returns <a href="q3socketdevice.html#Error-enum">NoError</a> for non-blocking sockets; this just means that you can call connect() again in a little while and it'll probably succeed.</p>
<!-- @@@connect -->
<!-- $$$error[overload1]$$$error -->
<h3 class="fn"><a name="error"></a><span class="type"><a href="q3socketdevice.html#Error-enum">Error</a></span> Q3SocketDevice::<span class="name">error</span> () const</h3>
<p>Returns the first error seen.</p>
<p><b>See also </b><a href="q3socketdevice.html#setError">setError</a>().</p>
<!-- @@@error -->
<!-- $$$flush[overload1]$$$flush -->
<h3 class="fn"><a name="flush"></a><span class="type">bool</span> Q3SocketDevice::<span class="name">flush</span> ()</h3>
<p>The current <a href="q3socketdevice.html" class="compat">Q3SocketDevice</a> implementation does not buffer at all, so this is a no-op. This function always returns true.</p>
<!-- @@@flush -->
<!-- $$$isValid[overload1]$$$isValid -->
<h3 class="fn"><a name="isValid"></a><span class="type">bool</span> Q3SocketDevice::<span class="name">isValid</span> () const</h3>
<p>Returns true if this is a valid socket; otherwise returns false.</p>
<p><b>See also </b><a href="q3socketdevice.html#socket">socket</a>().</p>
<!-- @@@isValid -->
<!-- $$$listen[overload1]$$$listenint -->
<h3 class="fn"><a name="listen"></a><span class="type">bool</span> Q3SocketDevice::<span class="name">listen</span> ( <span class="type">int</span> <i>backlog</i> )<tt> [virtual]</tt></h3>
<p>Specifies how many pending connections a server socket can have. Returns true if the operation was successful; otherwise returns false. A <i>backlog</i> value of 50 is quite common.</p>
<p>The listen() call only applies to sockets where <a href="q3socketdevice.html#type">type</a>() is <tt>Stream</tt>, i.e. not to <tt>Datagram</tt> sockets. listen() must not be called before <a href="q3socketdevice.html#bind">bind</a>() or after <a href="q3socketdevice.html#accept">accept</a>().</p>
<p><b>See also </b><a href="q3socketdevice.html#bind">bind</a>() and <a href="q3socketdevice.html#accept">accept</a>().</p>
<!-- @@@listen -->
<!-- $$$open[overload1]$$$openOpenMode -->
<h3 class="fn"><a name="open"></a><span class="type">bool</span> Q3SocketDevice::<span class="name">open</span> ( <span class="type"><a href="qiodevice.html#OpenModeFlag-enum">OpenMode</a></span> <i>mode</i> )<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qiodevice.html#open">QIODevice::open</a>().</p>
<p>Opens the socket using the specified <a href="qiodevice.html">QIODevice</a> file <i>mode</i>. This function is called from the <a href="q3socketdevice.html" class="compat">Q3SocketDevice</a> constructors and from the <a href="q3socketdevice.html#setSocket">setSocket</a>() function. You should not call it yourself.</p>
<p><b>See also </b><a href="q3socketdevice.html#close">close</a>().</p>
<!-- @@@open -->
<!-- $$$open$$$openint -->
<h3 class="fn"><a name="open-2"></a><span class="type">bool</span> Q3SocketDevice::<span class="name">open</span> ( <span class="type">int</span> <i>mode</i> )</h3>
<p>This is an overloaded function.</p>
<!-- @@@open -->
<!-- $$$peerAddress[overload1]$$$peerAddress -->
<h3 class="fn"><a name="peerAddress"></a><span class="type"><a href="qhostaddress.html">QHostAddress</a></span> Q3SocketDevice::<span class="name">peerAddress</span> () const</h3>
<p>Returns the address of the port this socket device is connected to. This may be 0.0.0.0 for a while, but is set to something sensible as soon as a sensible value is available.</p>
<p>Note that for Datagram sockets, this is the source port of the last packet received.</p>
<!-- @@@peerAddress -->
<!-- $$$peerPort[overload1]$$$peerPort -->
<h3 class="fn"><a name="peerPort"></a><span class="type"><a href="qtglobal-qt3.html#Q_UINT16-typedef">Q_UINT16</a></span> Q3SocketDevice::<span class="name">peerPort</span> () const</h3>
<p>Returns the port number of the port this socket device is connected to. This may be 0 for a while, but is set to something sensible as soon as a sensible value is available.</p>
<p>Note that for Datagram sockets, this is the source port of the last packet received, and that it is in native byte order.</p>
<!-- @@@peerPort -->
<!-- $$$port[overload1]$$$port -->
<h3 class="fn"><a name="port"></a><span class="type"><a href="qtglobal-qt3.html#Q_UINT16-typedef">Q_UINT16</a></span> Q3SocketDevice::<span class="name">port</span> () const</h3>
<p>Returns the port number of this socket device. This may be 0 for a while, but is set to something sensible as soon as a sensible value is available.</p>
<p>Note that Qt always uses native byte order, i.e. 67 is 67 in Qt; there is no need to call htons().</p>
<!-- @@@port -->
<!-- $$$protocol[overload1]$$$protocol -->
<h3 class="fn"><a name="protocol"></a><span class="type"><a href="q3socketdevice.html#Protocol-enum">Protocol</a></span> Q3SocketDevice::<span class="name">protocol</span> () const</h3>
<p>Returns the socket's protocol family, which is one of <tt>Unknown</tt>, <tt>IPv4</tt>, or <tt>IPv6</tt>.</p>
<p><a href="q3socketdevice.html" class="compat">Q3SocketDevice</a> either creates a socket with a well known protocol family or it uses an already existing socket. In the first case, this function returns the protocol family it was constructed with. In the second case, it tries to determine the protocol family of the socket; if this fails, it returns <tt>Unknown</tt>.</p>
<p><b>See also </b><a href="q3socketdevice.html#Protocol-enum">Protocol</a> and <a href="q3socketdevice.html#setSocket">setSocket</a>().</p>
<!-- @@@protocol -->
<!-- $$$readBlock[overload1]$$$readBlockchar*Q_ULONG -->
<h3 class="fn"><a name="readBlock"></a><span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> Q3SocketDevice::<span class="name">readBlock</span> ( <span class="type">char</span> * <i>data</i>, <span class="type"><a href="qtglobal-qt3.html#Q_ULONG-typedef">Q_ULONG</a></span> <i>maxlen</i> )</h3>
<p>Reads <i>maxlen</i> bytes from the socket into <i>data</i> and returns the number of bytes read. Returns -1 if an error occurred. Returning 0 is not an error. For Stream sockets, 0 is returned when the remote host closes the connection. For Datagram sockets, 0 is a valid datagram size.</p>
<!-- @@@readBlock -->
<!-- $$$readData[overload1]$$$readDatachar*qint64 -->
<h3 class="fn"><a name="readData"></a><span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> Q3SocketDevice::<span class="name">readData</span> ( <span class="type">char</span> * <i>data</i>, <span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> <i>maxlen</i> )<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qiodevice.html#readData">QIODevice::readData</a>().</p>
<p>Reads <i>maxlen</i> bytes from the socket into <i>data</i> and returns the number of bytes read. Returns -1 if an error occurred.</p>
<!-- @@@readData -->
<!-- $$$receiveBufferSize[overload1]$$$receiveBufferSize -->
<h3 class="fn"><a name="receiveBufferSize"></a><span class="type">int</span> Q3SocketDevice::<span class="name">receiveBufferSize</span> () const</h3>
<p>Returns the size of the operating system receive buffer.</p>
<p><b>See also </b><a href="q3socketdevice.html#setReceiveBufferSize">setReceiveBufferSize</a>().</p>
<!-- @@@receiveBufferSize -->
<!-- $$$sendBufferSize[overload1]$$$sendBufferSize -->
<h3 class="fn"><a name="sendBufferSize"></a><span class="type">int</span> Q3SocketDevice::<span class="name">sendBufferSize</span> () const</h3>
<p>Returns the size of the operating system send buffer.</p>
<p><b>See also </b><a href="q3socketdevice.html#setSendBufferSize">setSendBufferSize</a>().</p>
<!-- @@@sendBufferSize -->
<!-- $$$setAddressReusable[overload1]$$$setAddressReusablebool -->
<h3 class="fn"><a name="setAddressReusable"></a><span class="type">void</span> Q3SocketDevice::<span class="name">setAddressReusable</span> ( <span class="type">bool</span> <i>enable</i> )<tt> [virtual]</tt></h3>
<p>Sets the address of this socket to be usable by other sockets too if <i>enable</i> is true, and to be used exclusively by this socket if <i>enable</i> is false.</p>
<p>When a socket is reusable, other sockets can use the same port number (and IP address), which is generally useful. Of course other sockets cannot use the same (address,port,peer-address,peer-port) 4-tuple as this socket, so there is no risk of confusing the two TCP connections.</p>
<p><b>See also </b><a href="q3socketdevice.html#addressReusable">addressReusable</a>().</p>
<!-- @@@setAddressReusable -->
<!-- $$$setBlocking[overload1]$$$setBlockingbool -->
<h3 class="fn"><a name="setBlocking"></a><span class="type">void</span> Q3SocketDevice::<span class="name">setBlocking</span> ( <span class="type">bool</span> <i>enable</i> )<tt> [virtual]</tt></h3>
<p>Makes the socket blocking if <i>enable</i> is true or nonblocking if <i>enable</i> is false.</p>
<p>Sockets are blocking by default, but we recommend using nonblocking socket operations, especially for GUI programs that need to be responsive.</p>
<p><b>Warning:</b> On Windows, this function should be used with care since whenever you use a <a href="qsocketnotifier.html">QSocketNotifier</a> on Windows, the socket is immediately made nonblocking.</p>
<p><b>See also </b><a href="q3socketdevice.html#blocking">blocking</a>() and <a href="q3socketdevice.html#isValid">isValid</a>().</p>
<!-- @@@setBlocking -->
<!-- $$$setError[overload1]$$$setErrorError -->
<h3 class="fn"><a name="setError"></a><span class="type">void</span> Q3SocketDevice::<span class="name">setError</span> ( <span class="type"><a href="q3socketdevice.html#Error-enum">Error</a></span> <i>err</i> )<tt> [protected]</tt></h3>
<p>Allows subclasses to set the error state to <i>err</i>.</p>
<p><b>See also </b><a href="q3socketdevice.html#error">error</a>().</p>
<!-- @@@setError -->
<!-- $$$setReceiveBufferSize[overload1]$$$setReceiveBufferSizeuint -->
<h3 class="fn"><a name="setReceiveBufferSize"></a><span class="type">void</span> Q3SocketDevice::<span class="name">setReceiveBufferSize</span> ( <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>size</i> )<tt> [virtual]</tt></h3>
<p>Sets the size of the operating system receive buffer to <i>size</i>.</p>
<p>The operating system receive buffer size effectively limits two things: how much data can be in transit at any one moment, and how much data can be received in one iteration of the main event loop.</p>
<p>The default is operating system-dependent. A socket that receives large amounts of data is probably best with a buffer size of 49152.</p>
<p><b>See also </b><a href="q3socketdevice.html#receiveBufferSize">receiveBufferSize</a>().</p>
<!-- @@@setReceiveBufferSize -->
<!-- $$$setSendBufferSize[overload1]$$$setSendBufferSizeuint -->
<h3 class="fn"><a name="setSendBufferSize"></a><span class="type">void</span> Q3SocketDevice::<span class="name">setSendBufferSize</span> ( <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>size</i> )<tt> [virtual]</tt></h3>
<p>Sets the size of the operating system send buffer to <i>size</i>.</p>
<p>The operating system send buffer size effectively limits how much data can be in transit at any one moment.</p>
<p>The default is operating system-dependent. A socket that sends large amounts of data is probably best with a buffer size of 49152.</p>
<p><b>See also </b><a href="q3socketdevice.html#sendBufferSize">sendBufferSize</a>().</p>
<!-- @@@setSendBufferSize -->
<!-- $$$setSocket[overload1]$$$setSocketintType -->
<h3 class="fn"><a name="setSocket"></a><span class="type">void</span> Q3SocketDevice::<span class="name">setSocket</span> ( <span class="type">int</span> <i>socket</i>, <span class="type"><a href="q3socketdevice.html#Type-enum">Type</a></span> <i>type</i> )<tt> [virtual]</tt></h3>
<p>Sets the socket device to operate on the existing socket <i>socket</i>.</p>
<p>The <i>type</i> argument must match the actual socket type; use <tt>Q3SocketDevice::Stream</tt> for a reliable, connection-oriented TCP socket, or <a href="q3socketdevice.html#Type-enum">Q3SocketDevice::Datagram</a> for an unreliable, connectionless UDP socket.</p>
<p>Any existing socket is closed.</p>
<p><b>See also </b><a href="q3socketdevice.html#socket">socket</a>(), <a href="q3socketdevice.html#isValid">isValid</a>(), and <a href="q3socketdevice.html#close">close</a>().</p>
<!-- @@@setSocket -->
<!-- $$$size[overload1]$$$size -->
<h3 class="fn"><a name="size"></a><span class="type"><a href="qiodevice-qt3.html#Offset-typedef">Offset</a></span> Q3SocketDevice::<span class="name">size</span> () const<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qiodevice.html#size">QIODevice::size</a>().</p>
<p>The size is meaningless for a socket, therefore this function returns 0.</p>
<!-- @@@size -->
<!-- $$$socket[overload1]$$$socket -->
<h3 class="fn"><a name="socket"></a><span class="type">int</span> Q3SocketDevice::<span class="name">socket</span> () const</h3>
<p>Returns the socket number, or -1 if it is an invalid socket.</p>
<p><b>See also </b><a href="q3socketdevice.html#setSocket">setSocket</a>(), <a href="q3socketdevice.html#isValid">isValid</a>(), and <a href="q3socketdevice.html#type">type</a>().</p>
<!-- @@@socket -->
<!-- $$$type[overload1]$$$type -->
<h3 class="fn"><a name="type"></a><span class="type"><a href="q3socketdevice.html#Type-enum">Type</a></span> Q3SocketDevice::<span class="name">type</span> () const</h3>
<p>Returns the socket type which is either <a href="q3socketdevice.html#Type-enum">Q3SocketDevice::Stream</a> or <a href="q3socketdevice.html#Type-enum">Q3SocketDevice::Datagram</a>.</p>
<p><b>See also </b><a href="q3socketdevice.html#socket">socket</a>().</p>
<!-- @@@type -->
<!-- $$$waitForMore[overload1]$$$waitForMoreintbool* -->
<h3 class="fn"><a name="waitForMore"></a><span class="type"><a href="qtglobal-qt3.html#Q_LONG-typedef">Q_LONG</a></span> Q3SocketDevice::<span class="name">waitForMore</span> ( <span class="type">int</span> <i>msecs</i>, <span class="type">bool</span> * <i>timeout</i> = 0 ) const</h3>
<p>Wait up to <i>msecs</i> milliseconds for more data to be available. If <i>msecs</i> is -1 the call will block indefinitely.</p>
<p>Returns the number of bytes available for reading, or -1 if an error occurred.</p>
<p>If <i>timeout</i> is non-null and no error occurred (i.e. it does not return -1): this function sets *<i>timeout</i> to true, if the reason for returning was that the timeout was reached; otherwise it sets *<i>timeout</i> to false. This is useful to find out if the peer closed the connection.</p>
<p><b>Warning:</b> This is a blocking call and should be avoided in event driven applications.</p>
<p><b>See also </b><a href="q3socketdevice.html#bytesAvailable">bytesAvailable</a>().</p>
<!-- @@@waitForMore -->
<!-- $$$writeBlock[overload1]$$$writeBlockconstchar*Q_ULONG -->
<h3 class="fn"><a name="writeBlock"></a><span class="type"><a href="qtglobal-qt3.html#Q_LONG-typedef">Q_LONG</a></span> Q3SocketDevice::<span class="name">writeBlock</span> ( const <span class="type">char</span> * <i>data</i>, <span class="type"><a href="qtglobal-qt3.html#Q_ULONG-typedef">Q_ULONG</a></span> <i>len</i> )</h3>
<p>Writes <i>len</i> bytes to the socket from <i>data</i> and returns the number of bytes written. Returns -1 if an error occurred.</p>
<p>This is used for <a href="q3socketdevice.html#Type-enum">Q3SocketDevice::Stream</a> sockets.</p>
<!-- @@@writeBlock -->
<!-- $$$writeBlock$$$writeBlockconstchar*Q_ULONGconstQHostAddress&Q_UINT16 -->
<h3 class="fn"><a name="writeBlock-2"></a><span class="type"><a href="qtglobal-qt3.html#Q_LONG-typedef">Q_LONG</a></span> Q3SocketDevice::<span class="name">writeBlock</span> ( const <span class="type">char</span> * <i>data</i>, <span class="type"><a href="qtglobal-qt3.html#Q_ULONG-typedef">Q_ULONG</a></span> <i>len</i>, const <span class="type"><a href="qhostaddress.html">QHostAddress</a></span> & <i>host</i>, <span class="type"><a href="qtglobal-qt3.html#Q_UINT16-typedef">Q_UINT16</a></span> <i>port</i> )<tt> [virtual]</tt></h3>
<p>This is an overloaded function.</p>
<p>Writes <i>len</i> bytes to the socket from <i>data</i> and returns the number of bytes written. Returns -1 if an error occurred.</p>
<p>This is used for <a href="q3socketdevice.html#Type-enum">Q3SocketDevice::Datagram</a> sockets. You must specify the <i>host</i> and <i>port</i> of the destination of the data.</p>
<!-- @@@writeBlock -->
<!-- $$$writeData[overload1]$$$writeDataconstchar*qint64 -->
<h3 class="fn"><a name="writeData"></a><span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> Q3SocketDevice::<span class="name">writeData</span> ( const <span class="type">char</span> * <i>data</i>, <span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> <i>len</i> )<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qiodevice.html#writeData">QIODevice::writeData</a>().</p>
<p>Writes <i>len</i> bytes to the socket from <i>data</i> and returns the number of bytes written. Returns -1 if an error occurred.</p>
<p>This is used for <a href="q3socketdevice.html#Type-enum">Q3SocketDevice::Stream</a> sockets.</p>
<!-- @@@writeData -->
</div>
<div class="ft">
<span></span>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2012 Nokia Corporation and/or its
subsidiaries. Documentation contributions included herein are the copyrights of
their respective owners.</p>
<br />
<p>
The documentation provided herein is licensed under the terms of the
<a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation
License version 1.3</a> as published by the Free Software Foundation.</p>
<p>
Documentation sources may be obtained from <a href="http://www.qt-project.org">
www.qt-project.org</a>.</p>
<br />
<p>
Nokia, Qt and their respective logos are trademarks of Nokia Corporation
in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. <a title="Privacy Policy"
href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
</div>
</body>
</html>
|