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
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QLocalSocket Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QLocalSocket Class Reference<br /><sup><sup>[<a href="qtnetwork.html">QtNetwork</a> module]</sup></sup></h1><p>The QLocalSocket class provides a local socket. <a href="#details">More...</a></p>
<p>Inherits <a href="qiodevice.html">QIODevice</a>.</p><h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qlocalsocket.html#LocalSocketError-enum">LocalSocketError</a></b> { ConnectionRefusedError, PeerClosedError, ServerNotFoundError, SocketAccessError, ..., UnknownSocketError }</li><li><div class="fn" />enum <b><a href="qlocalsocket.html#LocalSocketState-enum">LocalSocketState</a></b> { UnconnectedState, ConnectingState, ConnectedState, ClosingState }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qlocalsocket.html#QLocalSocket">__init__</a></b> (<i>self</i>, QObject <i>parent</i> = None)</li><li><div class="fn" /><b><a href="qlocalsocket.html#abort">abort</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qlocalsocket.html#bytesAvailable">bytesAvailable</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qlocalsocket.html#bytesToWrite">bytesToWrite</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qlocalsocket.html#canReadLine">canReadLine</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qlocalsocket.html#close">close</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qlocalsocket.html#connectToServer">connectToServer</a></b> (<i>self</i>, QString <i>name</i>, QIODevice.OpenMode <i>mode</i> = QIODevice.ReadWrite)</li><li><div class="fn" /><b><a href="qlocalsocket.html#disconnectFromServer">disconnectFromServer</a></b> (<i>self</i>)</li><li><div class="fn" />LocalSocketError <b><a href="qlocalsocket.html#error">error</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qlocalsocket.html#flush">flush</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qlocalsocket.html#fullServerName">fullServerName</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qlocalsocket.html#isSequential">isSequential</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qlocalsocket.html#isValid">isValid</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qlocalsocket.html#readBufferSize">readBufferSize</a></b> (<i>self</i>)</li><li><div class="fn" />object <b><a href="qlocalsocket.html#readData">readData</a></b> (<i>self</i>, int <i>maxlen</i>)</li><li><div class="fn" />QString <b><a href="qlocalsocket.html#serverName">serverName</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qlocalsocket.html#setReadBufferSize">setReadBufferSize</a></b> (<i>self</i>, int <i>size</i>)</li><li><div class="fn" />bool <b><a href="qlocalsocket.html#setSocketDescriptor">setSocketDescriptor</a></b> (<i>self</i>, quintptr <i>socketDescriptor</i>, LocalSocketState <i>state</i> = QLocalSocket.ConnectedState, QIODevice.OpenMode <i>mode</i> = QIODevice.ReadWrite)</li><li><div class="fn" />quintptr <b><a href="qlocalsocket.html#socketDescriptor">socketDescriptor</a></b> (<i>self</i>)</li><li><div class="fn" />LocalSocketState <b><a href="qlocalsocket.html#state">state</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qlocalsocket.html#waitForBytesWritten">waitForBytesWritten</a></b> (<i>self</i>, int <i>msecs</i> = 30000)</li><li><div class="fn" />bool <b><a href="qlocalsocket.html#waitForConnected">waitForConnected</a></b> (<i>self</i>, int <i>msecs</i> = 30000)</li><li><div class="fn" />bool <b><a href="qlocalsocket.html#waitForDisconnected">waitForDisconnected</a></b> (<i>self</i>, int <i>msecs</i> = 30000)</li><li><div class="fn" />bool <b><a href="qlocalsocket.html#waitForReadyRead">waitForReadyRead</a></b> (<i>self</i>, int <i>msecs</i> = 30000)</li><li><div class="fn" />int <b><a href="qlocalsocket.html#writeData">writeData</a></b> (<i>self</i>, bytes)</li></ul><h3>Qt Signals</h3><ul><li><div class="fn" />void <b><a href="qlocalsocket.html#connected">connected</a></b> ()</li><li><div class="fn" />void <b><a href="qlocalsocket.html#disconnected">disconnected</a></b> ()</li><li><div class="fn" />void <b><a href="qlocalsocket.html#error-2">error</a></b> ( ::QLocalSocket::LocalSocketError)</li><li><div class="fn" />void <b><a href="qlocalsocket.html#stateChanged">stateChanged</a></b> ( ::QLocalSocket::LocalSocketState)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QLocalSocket class provides a local socket.</p>
<p>On Windows this is a named pipe and on Unix this is a local
domain socket.</p>
<p>If an error occurs, socketError() returns the type of error, and
<a href="qiodevice.html#errorString">errorString</a>() can be
called to get a human readable description of what happened.</p>
<p>Although QLocalSocket is designed for use with an event loop,
it's possible to use it without one. In that case, you must use
<a href="qlocalsocket.html#waitForConnected">waitForConnected</a>(),
<a href="qlocalsocket.html#waitForReadyRead">waitForReadyRead</a>(),
<a href="qlocalsocket.html#waitForBytesWritten">waitForBytesWritten</a>(),
and <a href="qlocalsocket.html#waitForDisconnected">waitForDisconnected</a>()
which blocks until the operation is complete or the timeout
expires.</p>
<p>Note that this feature is not supported on versions of Windows
earlier than Windows XP.</p>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="LocalSocketError-enum" />QLocalSocket.LocalSocketError</h3><p>The LocalServerError enumeration represents the errors that can
occur. The most recent error can be retrieved through a call to
<a href="qlocalsocket.html#error">QLocalSocket.error</a>().</p>
<table class="valuelist">
<tr class="odd" valign="top">
<th class="tblConst">Constant</th>
<th class="tblval">Value</th>
<th class="tbldscr">Description</th>
</tr>
<tr>
<td class="topAlign">
<tt>QLocalSocket.ConnectionRefusedError</tt></td>
<td class="topAlign">
<tt>QAbstractSocket.ConnectionRefusedError</tt></td>
<td class="topAlign">The connection was refused by the peer (or
timed out).</td>
</tr>
<tr>
<td class="topAlign"><tt>QLocalSocket.PeerClosedError</tt></td>
<td class="topAlign">
<tt>QAbstractSocket.RemoteHostClosedError</tt></td>
<td class="topAlign">The remote socket closed the connection. Note
that the client socket (i.e., this socket) will be closed after the
remote close notification has been sent.</td>
</tr>
<tr>
<td class="topAlign">
<tt>QLocalSocket.ServerNotFoundError</tt></td>
<td class="topAlign">
<tt>QAbstractSocket.HostNotFoundError</tt></td>
<td class="topAlign">The local socket name was not found.</td>
</tr>
<tr>
<td class="topAlign"><tt>QLocalSocket.SocketAccessError</tt></td>
<td class="topAlign">
<tt>QAbstractSocket.SocketAccessError</tt></td>
<td class="topAlign">The socket operation failed because the
application lacked the required privileges.</td>
</tr>
<tr>
<td class="topAlign">
<tt>QLocalSocket.SocketResourceError</tt></td>
<td class="topAlign">
<tt>QAbstractSocket.SocketResourceError</tt></td>
<td class="topAlign">The local system ran out of resources (e.g.,
too many sockets).</td>
</tr>
<tr>
<td class="topAlign"><tt>QLocalSocket.SocketTimeoutError</tt></td>
<td class="topAlign">
<tt>QAbstractSocket.SocketTimeoutError</tt></td>
<td class="topAlign">The socket operation timed out.</td>
</tr>
<tr>
<td class="topAlign">
<tt>QLocalSocket.DatagramTooLargeError</tt></td>
<td class="topAlign">
<tt>QAbstractSocket.DatagramTooLargeError</tt></td>
<td class="topAlign">The datagram was larger than the operating
system's limit (which can be as low as 8192 bytes).</td>
</tr>
<tr>
<td class="topAlign"><tt>QLocalSocket.ConnectionError</tt></td>
<td class="topAlign"><tt>QAbstractSocket.NetworkError</tt></td>
<td class="topAlign">An error occurred with the connection.</td>
</tr>
<tr>
<td class="topAlign">
<tt>QLocalSocket.UnsupportedSocketOperationError</tt></td>
<td class="topAlign">
<tt>QAbstractSocket.UnsupportedSocketOperationError</tt></td>
<td class="topAlign">The requested socket operation is not
supported by the local operating system.</td>
</tr>
<tr>
<td class="topAlign"><tt>QLocalSocket.UnknownSocketError</tt></td>
<td class="topAlign">
<tt>QAbstractSocket.UnknownSocketError</tt></td>
<td class="topAlign">An unidentified error occurred.</td>
</tr>
</table>
<h3 class="fn"><a name="LocalSocketState-enum" />QLocalSocket.LocalSocketState</h3><p>This enum describes the different states in which a socket can
be.</p>
<table class="valuelist">
<tr class="odd" valign="top">
<th class="tblConst">Constant</th>
<th class="tblval">Value</th>
<th class="tbldscr">Description</th>
</tr>
<tr>
<td class="topAlign"><tt>QLocalSocket.UnconnectedState</tt></td>
<td class="topAlign">
<tt>QAbstractSocket.UnconnectedState</tt></td>
<td class="topAlign">The socket is not connected.</td>
</tr>
<tr>
<td class="topAlign"><tt>QLocalSocket.ConnectingState</tt></td>
<td class="topAlign"><tt>QAbstractSocket.ConnectingState</tt></td>
<td class="topAlign">The socket has started establishing a
connection.</td>
</tr>
<tr>
<td class="topAlign"><tt>QLocalSocket.ConnectedState</tt></td>
<td class="topAlign"><tt>QAbstractSocket.ConnectedState</tt></td>
<td class="topAlign">A connection is established.</td>
</tr>
<tr>
<td class="topAlign"><tt>QLocalSocket.ClosingState</tt></td>
<td class="topAlign"><tt>QAbstractSocket.ClosingState</tt></td>
<td class="topAlign">The socket is about to close (data may still
be waiting to be written).</td>
</tr>
</table>
<p><b>See also</b> <a href="qlocalsocket.html#state">QLocalSocket.state</a>().</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QLocalSocket" />QLocalSocket.__init__ (<i>self</i>, <a href="qobject.html">QObject</a> <i>parent</i> = None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Creates a new local socket. The <i>parent</i> argument is passed
to <a href="qobject.html">QObject</a>'s constructor.</p>
<h3 class="fn"><a name="abort" />QLocalSocket.abort (<i>self</i>)</h3><p>Aborts the current connection and resets the socket. Unlike
<a href="qlocalsocket.html#disconnectFromServer">disconnectFromServer</a>(),
this function immediately closes the socket, clearing any pending
data in the write buffer.</p>
<p><b>See also</b> <a href="qlocalsocket.html#disconnectFromServer">disconnectFromServer</a>()
and <a href="qlocalsocket.html#close">close</a>().</p>
<h3 class="fn"><a name="bytesAvailable" />int QLocalSocket.bytesAvailable (<i>self</i>)</h3><p>Reimplemented from <a href="qiodevice.html#bytesAvailable">QIODevice.bytesAvailable</a>().</p>
<h3 class="fn"><a name="bytesToWrite" />int QLocalSocket.bytesToWrite (<i>self</i>)</h3><p>Reimplemented from <a href="qiodevice.html#bytesToWrite">QIODevice.bytesToWrite</a>().</p>
<h3 class="fn"><a name="canReadLine" />bool QLocalSocket.canReadLine (<i>self</i>)</h3><p>Reimplemented from <a href="qiodevice.html#canReadLine">QIODevice.canReadLine</a>().</p>
<h3 class="fn"><a name="close" />QLocalSocket.close (<i>self</i>)</h3><p>Reimplemented from <a href="qiodevice.html#close">QIODevice.close</a>().</p>
<h3 class="fn"><a name="connectToServer" />QLocalSocket.connectToServer (<i>self</i>, QString <i>name</i>, <a href="qiodevice-openmode.html">QIODevice.OpenMode</a> <i>mode</i> = QIODevice.ReadWrite)</h3><p>Attempts to make a connection to <i>name</i>.</p>
<p>The socket is opened in the given <i>openMode</i> and first
enters <a href="qlocalsocket.html#LocalSocketState-enum">ConnectingState</a>. It
then attempts to connect to the address or addresses returned by
the lookup. Finally, if a connection is established, <a href="qlocalsocket.html">QLocalSocket</a> enters <a href="qlocalsocket.html#LocalSocketState-enum">ConnectedState</a> and
emits <a href="qlocalsocket.html#connected">connected</a>().</p>
<p>At any point, the socket can emit <a href="qlocalsocket.html#error">error</a>() to signal that an error
occurred.</p>
<p>See also <a href="qlocalsocket.html#state">state</a>(), <a href="qlocalsocket.html#serverName">serverName</a>(), and <a href="qlocalsocket.html#waitForConnected">waitForConnected</a>().</p>
<h3 class="fn"><a name="disconnectFromServer" />QLocalSocket.disconnectFromServer (<i>self</i>)</h3><p>Attempts to close the socket. If there is pending data waiting
to be written, <a href="qlocalsocket.html">QLocalSocket</a> will
enter <a href="qlocalsocket.html#LocalSocketState-enum">ClosingState</a> and wait
until all data has been written. Eventually, it will enter <a href="qlocalsocket.html#LocalSocketState-enum">UnconnectedState</a> and
emit the disconnectedFromServer() signal.</p>
<p><b>See also</b> <a href="qlocalsocket.html#connectToServer">connectToServer</a>().</p>
<h3 class="fn"><a name="error" /><a href="qlocalsocket.html#LocalSocketError-enum">LocalSocketError</a> QLocalSocket.error (<i>self</i>)</h3><p>Returns the type of error that last occurred.</p>
<p><b>See also</b> <a href="qlocalsocket.html#state">state</a>()
and <a href="qiodevice.html#errorString">errorString</a>().</p>
<h3 class="fn"><a name="flush" />bool QLocalSocket.flush (<i>self</i>)</h3><p>This function writes as much as possible from the internal write
buffer to the socket, without blocking. If any data was written,
this function returns true; otherwise false is returned.</p>
<p>Call this function if you need <a href="qlocalsocket.html">QLocalSocket</a> to start sending buffered data
immediately. The number of bytes successfully written depends on
the operating system. In most cases, you do not need to call this
function, because <a href="qlocalsocket.html">QLocalSocket</a> will
start sending data automatically once control goes back to the
event loop. In the absence of an event loop, call <a href="qlocalsocket.html#waitForBytesWritten">waitForBytesWritten</a>()
instead.</p>
<p><b>See also</b> <a href="qiodevice.html#write">write</a>() and
<a href="qlocalsocket.html#waitForBytesWritten">waitForBytesWritten</a>().</p>
<h3 class="fn"><a name="fullServerName" />QString QLocalSocket.fullServerName (<i>self</i>)</h3><p>Returns the server path that the socket is connected to.</p>
<p><b>Note:</b> The return value of this function is platform
specific.</p>
<p><b>See also</b> <a href="qlocalsocket.html#connectToServer">connectToServer</a>() and
<a href="qlocalsocket.html#serverName">serverName</a>().</p>
<h3 class="fn"><a name="isSequential" />bool QLocalSocket.isSequential (<i>self</i>)</h3><p>Reimplemented from <a href="qiodevice.html#isSequential">QIODevice.isSequential</a>().</p>
<h3 class="fn"><a name="isValid" />bool QLocalSocket.isValid (<i>self</i>)</h3><p>Returns true if the socket is valid and ready for use; otherwise
returns false.</p>
<p><b>Note:</b> The socket's state must be <a href="qlocalsocket.html#LocalSocketState-enum">ConnectedState</a> before
reading and writing can occur.</p>
<p><b>See also</b> <a href="qlocalsocket.html#state">state</a>()
and <a href="qlocalsocket.html#connectToServer">connectToServer</a>().</p>
<h3 class="fn"><a name="readBufferSize" />int QLocalSocket.readBufferSize (<i>self</i>)</h3><p>Returns the size of the internal read buffer. This limits the
amount of data that the client can receive before you call <a href="qiodevice.html#read">read</a>() or <a href="qiodevice.html#readAll">readAll</a>(). A read buffer size of 0
(the default) means that the buffer has no size limit, ensuring
that no data is lost.</p>
<p><b>See also</b> <a href="qlocalsocket.html#setReadBufferSize">setReadBufferSize</a>() and
<a href="qiodevice.html#read">read</a>().</p>
<h3 class="fn"><a name="readData" />object QLocalSocket.readData (<i>self</i>, int <i>maxlen</i>)</h3><p>Reimplemented from <a href="qiodevice.html#readData">QIODevice.readData</a>().</p>
<h3 class="fn"><a name="serverName" />QString QLocalSocket.serverName (<i>self</i>)</h3><p>Returns the name of the peer as specified by <a href="qlocalsocket.html#connectToServer">connectToServer</a>(), or an
empty <a href="qstring.html">QString</a> if <a href="qlocalsocket.html#connectToServer">connectToServer</a>() has not
been called or it failed.</p>
<p><b>See also</b> <a href="qlocalsocket.html#connectToServer">connectToServer</a>() and
<a href="qlocalsocket.html#fullServerName">fullServerName</a>().</p>
<h3 class="fn"><a name="setReadBufferSize" />QLocalSocket.setReadBufferSize (<i>self</i>, int <i>size</i>)</h3><p>Sets the size of <a href="qlocalsocket.html">QLocalSocket</a>'s
internal read buffer to be <i>size</i> bytes.</p>
<p>If the buffer size is limited to a certain size, <a href="qlocalsocket.html">QLocalSocket</a> won't buffer more than this
size of data. Exceptionally, a buffer size of 0 means that the read
buffer is unlimited and all incoming data is buffered. This is the
default.</p>
<p>This option is useful if you only read the data at certain
points in time (e.g., in a real-time streaming application) or if
you want to protect your socket against receiving too much data,
which may eventually cause your application to run out of
memory.</p>
<p><b>See also</b> <a href="qlocalsocket.html#readBufferSize">readBufferSize</a>() and
<a href="qiodevice.html#read">read</a>().</p>
<h3 class="fn"><a name="setSocketDescriptor" />bool QLocalSocket.setSocketDescriptor (<i>self</i>, quintptr <i>socketDescriptor</i>, <a href="qlocalsocket.html#LocalSocketState-enum">LocalSocketState</a> <i>state</i> = QLocalSocket.ConnectedState, <a href="qiodevice-openmode.html">QIODevice.OpenMode</a> <i>mode</i> = QIODevice.ReadWrite)</h3><p>Initializes <a href="qlocalsocket.html">QLocalSocket</a> with
the native socket descriptor <i>socketDescriptor</i>. Returns true
if socketDescriptor is accepted as a valid socket descriptor;
otherwise returns false. The socket is opened in the mode specified
by <i>openMode</i>, and enters the socket state specified by
<i>socketState</i>.</p>
<p><b>Note:</b> It is not possible to initialize two local sockets
with the same native socket descriptor.</p>
<p><b>See also</b> <a href="qlocalsocket.html#socketDescriptor">socketDescriptor</a>(),
<a href="qlocalsocket.html#state">state</a>(), and <a href="qiodevice.html#openMode">openMode</a>().</p>
<h3 class="fn"><a name="socketDescriptor" />quintptr QLocalSocket.socketDescriptor (<i>self</i>)</h3><p>Returns the native socket descriptor of the <a href="qlocalsocket.html">QLocalSocket</a> object if this is available;
otherwise returns -1.</p>
<p>The socket descriptor is not available when <a href="qlocalsocket.html">QLocalSocket</a> is in <a href="qlocalsocket.html#LocalSocketState-enum">UnconnectedState</a>.</p>
<p><b>See also</b> <a href="qlocalsocket.html#setSocketDescriptor">setSocketDescriptor</a>().</p>
<h3 class="fn"><a name="state" /><a href="qlocalsocket.html#LocalSocketState-enum">LocalSocketState</a> QLocalSocket.state (<i>self</i>)</h3><p>Returns the state of the socket.</p>
<p><b>See also</b> <a href="qlocalsocket.html#error">error</a>().</p>
<h3 class="fn"><a name="waitForBytesWritten" />bool QLocalSocket.waitForBytesWritten (<i>self</i>, int <i>msecs</i> = 30000)</h3><p>Reimplemented from <a href="qiodevice.html#waitForBytesWritten">QIODevice.waitForBytesWritten</a>().</p>
<h3 class="fn"><a name="waitForConnected" />bool QLocalSocket.waitForConnected (<i>self</i>, int <i>msecs</i> = 30000)</h3><p>Waits until the socket is connected, up to <i>msecs</i>
milliseconds. If the connection has been established, this function
returns true; otherwise it returns false. In the case where it
returns false, you can call <a href="qlocalsocket.html#error">error</a>() to determine the cause of the
error.</p>
<p>The following example waits up to one second for a connection to
be established:</p>
<pre class="cpp">
socket<span class="operator">-</span><span class="operator">></span><a href="qlocalsocket.html#connectToServer">connectToServer</a>(<span class="string">"market"</span>);
<span class="keyword">if</span> (socket<span class="operator">-</span><span class="operator">></span>waitForConnected(<span class="number">1000</span>))
<a href="qtcore.html#qDebug">qDebug</a>(<span class="string">"Connected!"</span>);
</pre>
<p>If <i>msecs</i> is -1, this function will not time out.</p>
<p><b>See also</b> <a href="qlocalsocket.html#connectToServer">connectToServer</a>() and
<a href="qlocalsocket.html#connected">connected</a>().</p>
<h3 class="fn"><a name="waitForDisconnected" />bool QLocalSocket.waitForDisconnected (<i>self</i>, int <i>msecs</i> = 30000)</h3><p>Waits until the socket has disconnected, up to <i>msecs</i>
milliseconds. If the connection has been disconnected, this
function returns true; otherwise it returns false. In the case
where it returns false, you can call <a href="qlocalsocket.html#error">error</a>() to determine the cause of the
error.</p>
<p>The following example waits up to one second for a connection to
be closed:</p>
<pre class="cpp">
socket<span class="operator">-</span><span class="operator">></span><a href="qlocalsocket.html#disconnectFromServer">disconnectFromServer</a>();
<span class="keyword">if</span> (socket<span class="operator">-</span><span class="operator">></span>waitForDisconnected(<span class="number">1000</span>))
<a href="qtcore.html#qDebug">qDebug</a>(<span class="string">"Disconnected!"</span>);
</pre>
<p>If <i>msecs</i> is -1, this function will not time out.</p>
<p><b>See also</b> <a href="qlocalsocket.html#disconnectFromServer">disconnectFromServer</a>()
and <a href="qlocalsocket.html#close">close</a>().</p>
<h3 class="fn"><a name="waitForReadyRead" />bool QLocalSocket.waitForReadyRead (<i>self</i>, int <i>msecs</i> = 30000)</h3><p>Reimplemented from <a href="qiodevice.html#waitForReadyRead">QIODevice.waitForReadyRead</a>().</p>
<p>This function blocks until data is available for reading and the
<a href="qiodevice.html#readyRead">readyRead()</a> signal has been
emitted. The function will timeout after <i>msecs</i> milliseconds;
the default timeout is 30000 milliseconds.</p>
<p>The function returns true if data is available for reading;
otherwise it returns false (if an error occurred or the operation
timed out).</p>
<p><b>See also</b> <a href="qlocalsocket.html#waitForBytesWritten">waitForBytesWritten</a>().</p>
<h3 class="fn"><a name="writeData" />int QLocalSocket.writeData (<i>self</i>, bytes)</h3><p>Reimplemented from <a href="qiodevice.html#writeData">QIODevice.writeData</a>().</p>
<hr /><h2>Qt Signal Documentation</h2><h3 class="fn"><a name="connected" />void connected ()</h3><p>This is the default overload of this signal.</p><p>This signal is emitted after <a href="qlocalsocket.html#connectToServer">connectToServer</a>() has been
called and a connection has been successfully established.</p>
<p><b>See also</b> <a href="qlocalsocket.html#connectToServer">connectToServer</a>() and
<a href="qlocalsocket.html#disconnected">disconnected</a>().</p>
<h3 class="fn"><a name="disconnected" />void disconnected ()</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when the socket has been
disconnected.</p>
<p><b>See also</b> <a href="qlocalsocket.html#connectToServer">connectToServer</a>(), <a href="qlocalsocket.html#disconnectFromServer">disconnectFromServer</a>(),
<a href="qlocalsocket.html#abort">abort</a>(), and <a href="qlocalsocket.html#connected">connected</a>().</p>
<h3 class="fn"><a name="error-2" />void error ( ::QLocalSocket::LocalSocketError)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted after an error occurred. The
<i>socketError</i> parameter describes the type of error that
occurred.</p>
<p><a href="qlocalsocket.html#LocalSocketError-enum">QLocalSocket.LocalSocketError</a>
is not a registered metatype, so for queued connections, you will
have to register it with <a href="qmetatype.html#Q_DECLARE_METATYPE">Q_DECLARE_METATYPE</a>() and
<a href="qmetatype.html#qRegisterMetaType">qRegisterMetaType</a>().</p>
<p><b>See also</b> <a href="qlocalsocket.html#error">error</a>(),
<a href="qiodevice.html#errorString">errorString</a>(), and
<a href="custom-types.html">Creating Custom Qt Types</a>.</p>
<h3 class="fn"><a name="stateChanged" />void stateChanged ( ::QLocalSocket::LocalSocketState)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted whenever <a href="qlocalsocket.html">QLocalSocket</a>'s state changes. The
<i>socketState</i> parameter is the new state.</p>
<p>QLocalSocket.SocketState is not a registered metatype, so for
queued connections, you will have to register it with <a href="qmetatype.html#Q_DECLARE_METATYPE">Q_DECLARE_METATYPE</a>() and
<a href="qmetatype.html#qRegisterMetaType">qRegisterMetaType</a>().</p>
<p><b>See also</b> <a href="qlocalsocket.html#state">state</a>()
and <a href="custom-types.html">Creating Custom Qt Types</a>.</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.12.1 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qt.io">The Qt Company</a> 2015</td><td align="right" width="25%">Qt 4.8.7</td></tr></table></div></address></body></html>
|