<?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" /> <!-- qlocalsocket.cpp --> <title>Qt 4.8: QLocalSocket Class Reference</title> <link rel="stylesheet" type="text/css" href="style/style.css" /> <script src="scripts/jquery.js" type="text/javascript"></script> <script src="scripts/functions.js" type="text/javascript"></script> <link rel="stylesheet" type="text/css" href="style/superfish.css" /> <link rel="stylesheet" type="text/css" href="style/narrow.css" /> <!--[if IE]> <meta name="MSSmartTagsPreventParsing" content="true"> <meta http-equiv="imagetoolbar" content="no"> <![endif]--> <!--[if lt IE 7]> <link rel="stylesheet" type="text/css" href="style/style_ie6.css"> <![endif]--> <!--[if IE 7]> <link rel="stylesheet" type="text/css" href="style/style_ie7.css"> <![endif]--> <!--[if IE 8]> <link rel="stylesheet" type="text/css" href="style/style_ie8.css"> <![endif]--> <script src="scripts/superfish.js" type="text/javascript"></script> <script src="scripts/narrow.js" type="text/javascript"></script> </head> <body class="" onload="CheckEmptyAndLoadList();"> <div class="header" id="qtdocheader"> <div class="content"> <div id="nav-logo"> <a href="index.html">Home</a></div> <a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a> <div id="narrowsearch"></div> <div id="nav-topright"> <ul> <li class="nav-topright-home"><a href="http://qt.digia.com/">Qt HOME</a></li> <li class="nav-topright-dev"><a href="http://qt-project.org/">DEV</a></li> <li class="nav-topright-doc nav-topright-doc-active"><a href="http://qt-project.org/doc/"> DOC</a></li> <li class="nav-topright-blog"><a href="http://blog.qt.digia.com/">BLOG</a></li> </ul> </div> <div id="shortCut"> <ul> <li class="shortCut-topleft-inactive"><span><a href="index.html">Qt 4.8</a></span></li> <li class="shortCut-topleft-active"><a href="http://qt-project.org/doc/">ALL VERSIONS </a></li> </ul> </div> <ul class="sf-menu" id="narrowmenu"> <li><a href="#">API Lookup</a> <ul> <li><a href="classes.html">Class index</a></li> <li><a href="functions.html">Function index</a></li> <li><a href="modules.html">Modules</a></li> <li><a href="namespaces.html">Namespaces</a></li> <li><a href="qtglobal.html">Global Declarations</a></li> <li><a href="qdeclarativeelements.html">QML elements</a></li> </ul> </li> <li><a href="#">Qt Topics</a> <ul> <li><a href="qt-basic-concepts.html">Programming with Qt</a></li> <li><a href="qtquick.html">Device UIs & Qt Quick</a></li> <li><a href="qt-gui-concepts.html">UI Design with Qt</a></li> <li><a href="supported-platforms.html">Supported Platforms</a></li> <li><a href="technology-apis.html">Qt and Key Technologies</a></li> <li><a href="best-practices.html">How-To's and Best Practices</a></li> </ul> </li> <li><a href="#">Examples</a> <ul> <li><a href="all-examples.html">Examples</a></li> <li><a href="tutorials.html">Tutorials</a></li> <li><a href="demos.html">Demos</a></li> <li><a href="qdeclarativeexamples.html">QML Examples</a></li> </ul> </li> </ul> </div> </div> <div class="wrapper"> <div class="hd"> <span></span> </div> <div class="bd group"> <div class="sidebar"> <div class="searchlabel"> Search index:</div> <div class="search" id="sidebarsearch"> <form id="qtdocsearch" action="" onsubmit="return false;"> <fieldset> <input type="text" name="searchstring" id="pageType" value="" /> <div id="resultdialog"> <a href="#" id="resultclose">Close</a> <p id="resultlinks" class="all"><a href="#" id="showallresults">All</a> | <a href="#" id="showapiresults">API</a> | <a href="#" id="showarticleresults">Articles</a> | <a href="#" id="showexampleresults">Examples</a></p> <p id="searchcount" class="all"><span id="resultcount"></span><span id="apicount"></span><span id="articlecount"></span><span id="examplecount"></span> results:</p> <ul id="resultlist" class="all"> </ul> </div> </fieldset> </form> </div> <div class="box first bottombar" id="lookup"> <h2 title="API Lookup"><span></span> API Lookup</h2> <div id="list001" class="list"> <ul id="ul001" > <li class="defaultLink"><a href="classes.html">Class index</a></li> <li class="defaultLink"><a href="functions.html">Function index</a></li> <li class="defaultLink"><a href="modules.html">Modules</a></li> <li class="defaultLink"><a href="namespaces.html">Namespaces</a></li> <li class="defaultLink"><a href="qtglobal.html">Global Declarations</a></li> <li class="defaultLink"><a href="qdeclarativeelements.html">QML elements</a></li> </ul> </div> </div> <div class="box bottombar" id="topics"> <h2 title="Qt Topics"><span></span> Qt Topics</h2> <div id="list002" class="list"> <ul id="ul002" > <li class="defaultLink"><a href="qt-basic-concepts.html">Programming with Qt</a></li> <li class="defaultLink"><a href="qtquick.html">Device UIs & Qt Quick</a></li> <li class="defaultLink"><a href="qt-gui-concepts.html">UI Design with Qt</a></li> <li class="defaultLink"><a href="supported-platforms.html">Supported Platforms</a></li> <li class="defaultLink"><a href="technology-apis.html">Qt and Key Technologies</a></li> <li class="defaultLink"><a href="best-practices.html">How-To's and Best Practices</a></li> </ul> </div> </div> <div class="box" id="examples"> <h2 title="Examples"><span></span> Examples</h2> <div id="list003" class="list"> <ul id="ul003"> <li class="defaultLink"><a href="all-examples.html">Examples</a></li> <li class="defaultLink"><a href="tutorials.html">Tutorials</a></li> <li class="defaultLink"><a href="demos.html">Demos</a></li> <li class="defaultLink"><a href="qdeclarativeexamples.html">QML Examples</a></li> </ul> </div> </div> </div> <div class="wrap"> <div class="toolbar"> <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="qtnetwork.html">QtNetwork</a></li> <li>QLocalSocket</li> </ul> </div> <div class="toolbuttons toolblock"> <ul> <li id="smallA" class="t_button">A</li> <li id="medA" class="t_button active">A</li> <li id="bigA" class="t_button">A</li> <li id="print" class="t_button"><a href="javascript:this.print();"> <span>Print</span></a></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="#signals">Signals</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">QLocalSocket Class Reference</h1> <!-- $$$QLocalSocket-brief --> <p>The QLocalSocket class provides a local socket. <a href="#details">More...</a></p> <!-- @@@QLocalSocket --> <pre class="cpp"> <span class="preprocessor">#include <QLocalSocket></span></pre><p><b>Inherits: </b><a href="qiodevice.html">QIODevice</a>.</p> <p>This class was introduced in Qt 4.4.</p> <ul> <li><a href="qlocalsocket-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="qlocalsocket.html#LocalSocketError-enum">LocalSocketError</a></b> { ConnectionRefusedError, PeerClosedError, ServerNotFoundError, SocketAccessError, ..., UnknownSocketError }</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qlocalsocket.html#LocalSocketState-enum">LocalSocketState</a></b> { UnconnectedState, ConnectingState, ConnectedState, ClosingState }</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="qlocalsocket.html#QLocalSocket">QLocalSocket</a></b> ( QObject * <i>parent</i> = 0 )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qlocalsocket.html#dtor.QLocalSocket">~QLocalSocket</a></b> ()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlocalsocket.html#abort">abort</a></b> ()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlocalsocket.html#connectToServer">connectToServer</a></b> ( const QString & <i>name</i>, OpenMode <i>openMode</i> = ReadWrite )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlocalsocket.html#disconnectFromServer">disconnectFromServer</a></b> ()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> LocalSocketError </td><td class="memItemRight bottomAlign"><b><a href="qlocalsocket.html#error">error</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qlocalsocket.html#flush">flush</a></b> ()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qlocalsocket.html#fullServerName">fullServerName</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qlocalsocket.html#isValid">isValid</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> qint64 </td><td class="memItemRight bottomAlign"><b><a href="qlocalsocket.html#readBufferSize">readBufferSize</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qlocalsocket.html#serverName">serverName</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlocalsocket.html#setReadBufferSize">setReadBufferSize</a></b> ( qint64 <i>size</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qlocalsocket.html#setSocketDescriptor">setSocketDescriptor</a></b> ( quintptr <i>socketDescriptor</i>, LocalSocketState <i>socketState</i> = ConnectedState, OpenMode <i>openMode</i> = ReadWrite )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> quintptr </td><td class="memItemRight bottomAlign"><b><a href="qlocalsocket.html#socketDescriptor">socketDescriptor</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> LocalSocketState </td><td class="memItemRight bottomAlign"><b><a href="qlocalsocket.html#state">state</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qlocalsocket.html#waitForConnected">waitForConnected</a></b> ( int <i>msecs</i> = 30000 )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qlocalsocket.html#waitForDisconnected">waitForDisconnected</a></b> ( int <i>msecs</i> = 30000 )</td></tr> </table> <a name="reimplemented-public-functions"></a> <h2>Reimplemented Public Functions</h2> <table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> virtual qint64 </td><td class="memItemRight bottomAlign"><b><a href="qlocalsocket.html#bytesAvailable">bytesAvailable</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual qint64 </td><td class="memItemRight bottomAlign"><b><a href="qlocalsocket.html#bytesToWrite">bytesToWrite</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qlocalsocket.html#canReadLine">canReadLine</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qlocalsocket.html#close">close</a></b> ()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qlocalsocket.html#isSequential">isSequential</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qlocalsocket.html#waitForBytesWritten">waitForBytesWritten</a></b> ( int <i>msecs</i> = 30000 )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qlocalsocket.html#waitForReadyRead">waitForReadyRead</a></b> ( int <i>msecs</i> = 30000 )</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="signals"></a> <h2>Signals</h2> <table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlocalsocket.html#connected">connected</a></b> ()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlocalsocket.html#disconnected">disconnected</a></b> ()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlocalsocket.html#error-2">error</a></b> ( QLocalSocket::LocalSocketError <i>socketError</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlocalsocket.html#stateChanged">stateChanged</a></b> ( QLocalSocket::LocalSocketState <i>socketState</i> )</td></tr> </table> <ul> <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> </ul> <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="qlocalsocket.html#readData">readData</a></b> ( char * <i>data</i>, qint64 <i>c</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual qint64 </td><td class="memItemRight bottomAlign"><b><a href="qlocalsocket.html#writeData">writeData</a></b> ( const char * <i>data</i>, qint64 <i>c</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">7 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li> <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> <a name="details"></a> <!-- $$$QLocalSocket-description --> <div class="descr"> <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> </div> <p><b>See also </b><a href="qlocalserver.html">QLocalServer</a>.</p> <!-- @@@QLocalSocket --> <div class="types"> <h2>Member Type Documentation</h2> <!-- $$$LocalSocketError$$$ConnectionRefusedError$$$PeerClosedError$$$ServerNotFoundError$$$SocketAccessError$$$SocketResourceError$$$SocketTimeoutError$$$DatagramTooLargeError$$$ConnectionError$$$UnsupportedSocketOperationError$$$UnknownSocketError --> <h3 class="fn"><a name="LocalSocketError-enum"></a>enum QLocalSocket::<span class="name">LocalSocketError</span></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 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>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> <!-- @@@LocalSocketError --> <!-- $$$LocalSocketState$$$UnconnectedState$$$ConnectingState$$$ConnectedState$$$ClosingState --> <h3 class="fn"><a name="LocalSocketState-enum"></a>enum QLocalSocket::<span class="name">LocalSocketState</span></h3> <p>This enum describes the different states in which a socket can be.</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>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> <!-- @@@LocalSocketState --> </div> <div class="func"> <h2>Member Function Documentation</h2> <!-- $$$QLocalSocket[overload1]$$$QLocalSocketQObject* --> <h3 class="fn"><a name="QLocalSocket"></a>QLocalSocket::<span class="name">QLocalSocket</span> ( <span class="type"><a href="qobject.html">QObject</a></span> * <i>parent</i> = 0 )</h3> <p>Creates a new local socket. The <i>parent</i> argument is passed to <a href="qobject.html">QObject</a>'s constructor.</p> <!-- @@@QLocalSocket --> <!-- $$$~QLocalSocket[overload1]$$$~QLocalSocket --> <h3 class="fn"><a name="dtor.QLocalSocket"></a>QLocalSocket::<span class="name">~QLocalSocket</span> ()</h3> <p>Destroys the socket, closing the connection if necessary.</p> <!-- @@@~QLocalSocket --> <!-- $$$abort[overload1]$$$abort --> <h3 class="fn"><a name="abort"></a><span class="type">void</span> QLocalSocket::<span class="name">abort</span> ()</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> <!-- @@@abort --> <!-- $$$bytesAvailable[overload1]$$$bytesAvailable --> <h3 class="fn"><a name="bytesAvailable"></a><span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> QLocalSocket::<span class="name">bytesAvailable</span> () const<tt> [virtual]</tt></h3> <p>Reimplemented from <a href="qiodevice.html#bytesAvailable">QIODevice::bytesAvailable</a>().</p> <!-- @@@bytesAvailable --> <!-- $$$bytesToWrite[overload1]$$$bytesToWrite --> <h3 class="fn"><a name="bytesToWrite"></a><span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> QLocalSocket::<span class="name">bytesToWrite</span> () const<tt> [virtual]</tt></h3> <p>Reimplemented from <a href="qiodevice.html#bytesToWrite">QIODevice::bytesToWrite</a>().</p> <!-- @@@bytesToWrite --> <!-- $$$canReadLine[overload1]$$$canReadLine --> <h3 class="fn"><a name="canReadLine"></a><span class="type">bool</span> QLocalSocket::<span class="name">canReadLine</span> () const<tt> [virtual]</tt></h3> <p>Reimplemented from <a href="qiodevice.html#canReadLine">QIODevice::canReadLine</a>().</p> <!-- @@@canReadLine --> <!-- $$$close[overload1]$$$close --> <h3 class="fn"><a name="close"></a><span class="type">void</span> QLocalSocket::<span class="name">close</span> ()<tt> [virtual]</tt></h3> <p>Reimplemented from <a href="qiodevice.html#close">QIODevice::close</a>().</p> <!-- @@@close --> <!-- $$$connectToServer[overload1]$$$connectToServerconstQString&OpenMode --> <h3 class="fn"><a name="connectToServer"></a><span class="type">void</span> QLocalSocket::<span class="name">connectToServer</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>name</i>, <span class="type"><a href="qiodevice.html#OpenModeFlag-enum">OpenMode</a></span> <i>openMode</i> = 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> <!-- @@@connectToServer --> <!-- $$$connected[overload1]$$$connected --> <h3 class="fn"><a name="connected"></a><span class="type">void</span> QLocalSocket::<span class="name">connected</span> ()<tt> [signal]</tt></h3> <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> <!-- @@@connected --> <!-- $$$disconnectFromServer[overload1]$$$disconnectFromServer --> <h3 class="fn"><a name="disconnectFromServer"></a><span class="type">void</span> QLocalSocket::<span class="name">disconnectFromServer</span> ()</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> <!-- @@@disconnectFromServer --> <!-- $$$disconnected[overload1]$$$disconnected --> <h3 class="fn"><a name="disconnected"></a><span class="type">void</span> QLocalSocket::<span class="name">disconnected</span> ()<tt> [signal]</tt></h3> <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> <!-- @@@disconnected --> <!-- $$$error[overload1]$$$error --> <h3 class="fn"><a name="error"></a><span class="type"><a href="qlocalsocket.html#LocalSocketError-enum">LocalSocketError</a></span> QLocalSocket::<span class="name">error</span> () const</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> <!-- @@@error --> <!-- $$$error$$$errorQLocalSocket::LocalSocketError --> <h3 class="fn"><a name="error-2"></a><span class="type">void</span> QLocalSocket::<span class="name">error</span> ( <span class="type"><a href="qlocalsocket.html#LocalSocketError-enum">QLocalSocket::LocalSocketError</a></span> <i>socketError</i> )<tt> [signal]</tt></h3> <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> <!-- @@@error --> <!-- $$$flush[overload1]$$$flush --> <h3 class="fn"><a name="flush"></a><span class="type">bool</span> QLocalSocket::<span class="name">flush</span> ()</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> <!-- @@@flush --> <!-- $$$fullServerName[overload1]$$$fullServerName --> <h3 class="fn"><a name="fullServerName"></a><span class="type"><a href="qstring.html">QString</a></span> QLocalSocket::<span class="name">fullServerName</span> () const</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> <!-- @@@fullServerName --> <!-- $$$isSequential[overload1]$$$isSequential --> <h3 class="fn"><a name="isSequential"></a><span class="type">bool</span> QLocalSocket::<span class="name">isSequential</span> () const<tt> [virtual]</tt></h3> <p>Reimplemented from <a href="qiodevice.html#isSequential">QIODevice::isSequential</a>().</p> <!-- @@@isSequential --> <!-- $$$isValid[overload1]$$$isValid --> <h3 class="fn"><a name="isValid"></a><span class="type">bool</span> QLocalSocket::<span class="name">isValid</span> () const</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> <!-- @@@isValid --> <!-- $$$readBufferSize[overload1]$$$readBufferSize --> <h3 class="fn"><a name="readBufferSize"></a><span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> QLocalSocket::<span class="name">readBufferSize</span> () const</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> <!-- @@@readBufferSize --> <!-- $$$readData[overload1]$$$readDatachar*qint64 --> <h3 class="fn"><a name="readData"></a><span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> QLocalSocket::<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>c</i> )<tt> [virtual protected]</tt></h3> <p>Reimplemented from <a href="qiodevice.html#readData">QIODevice::readData</a>().</p> <!-- @@@readData --> <!-- $$$serverName[overload1]$$$serverName --> <h3 class="fn"><a name="serverName"></a><span class="type"><a href="qstring.html">QString</a></span> QLocalSocket::<span class="name">serverName</span> () const</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> <!-- @@@serverName --> <!-- $$$setReadBufferSize[overload1]$$$setReadBufferSizeqint64 --> <h3 class="fn"><a name="setReadBufferSize"></a><span class="type">void</span> QLocalSocket::<span class="name">setReadBufferSize</span> ( <span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> <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> <!-- @@@setReadBufferSize --> <!-- $$$setSocketDescriptor[overload1]$$$setSocketDescriptorquintptrLocalSocketStateOpenMode --> <h3 class="fn"><a name="setSocketDescriptor"></a><span class="type">bool</span> QLocalSocket::<span class="name">setSocketDescriptor</span> ( <span class="type"><a href="qtglobal.html#quintptr-typedef">quintptr</a></span> <i>socketDescriptor</i>, <span class="type"><a href="qlocalsocket.html#LocalSocketState-enum">LocalSocketState</a></span> <i>socketState</i> = ConnectedState, <span class="type"><a href="qiodevice.html#OpenModeFlag-enum">OpenMode</a></span> <i>openMode</i> = 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> <!-- @@@setSocketDescriptor --> <!-- $$$socketDescriptor[overload1]$$$socketDescriptor --> <h3 class="fn"><a name="socketDescriptor"></a><span class="type"><a href="qtglobal.html#quintptr-typedef">quintptr</a></span> QLocalSocket::<span class="name">socketDescriptor</span> () const</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> <!-- @@@socketDescriptor --> <!-- $$$state[overload1]$$$state --> <h3 class="fn"><a name="state"></a><span class="type"><a href="qlocalsocket.html#LocalSocketState-enum">LocalSocketState</a></span> QLocalSocket::<span class="name">state</span> () const</h3> <p>Returns the state of the socket.</p> <p><b>See also </b><a href="qlocalsocket.html#error">error</a>().</p> <!-- @@@state --> <!-- $$$stateChanged[overload1]$$$stateChangedQLocalSocket::LocalSocketState --> <h3 class="fn"><a name="stateChanged"></a><span class="type">void</span> QLocalSocket::<span class="name">stateChanged</span> ( <span class="type"><a href="qlocalsocket.html#LocalSocketState-enum">QLocalSocket::LocalSocketState</a></span> <i>socketState</i> )<tt> [signal]</tt></h3> <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> <!-- @@@stateChanged --> <!-- $$$waitForBytesWritten[overload1]$$$waitForBytesWrittenint --> <h3 class="fn"><a name="waitForBytesWritten"></a><span class="type">bool</span> QLocalSocket::<span class="name">waitForBytesWritten</span> ( <span class="type">int</span> <i>msecs</i> = 30000 )<tt> [virtual]</tt></h3> <p>Reimplemented from <a href="qiodevice.html#waitForBytesWritten">QIODevice::waitForBytesWritten</a>().</p> <!-- @@@waitForBytesWritten --> <!-- $$$waitForConnected[overload1]$$$waitForConnectedint --> <h3 class="fn"><a name="waitForConnected"></a><span class="type">bool</span> QLocalSocket::<span class="name">waitForConnected</span> ( <span class="type">int</span> <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="qtglobal.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> <!-- @@@waitForConnected --> <!-- $$$waitForDisconnected[overload1]$$$waitForDisconnectedint --> <h3 class="fn"><a name="waitForDisconnected"></a><span class="type">bool</span> QLocalSocket::<span class="name">waitForDisconnected</span> ( <span class="type">int</span> <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="qtglobal.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> <!-- @@@waitForDisconnected --> <!-- $$$waitForReadyRead[overload1]$$$waitForReadyReadint --> <h3 class="fn"><a name="waitForReadyRead"></a><span class="type">bool</span> QLocalSocket::<span class="name">waitForReadyRead</span> ( <span class="type">int</span> <i>msecs</i> = 30000 )<tt> [virtual]</tt></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> <!-- @@@waitForReadyRead --> <!-- $$$writeData[overload1]$$$writeDataconstchar*qint64 --> <h3 class="fn"><a name="writeData"></a><span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> QLocalSocket::<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>c</i> )<tt> [virtual protected]</tt></h3> <p>Reimplemented from <a href="qiodevice.html#writeData">QIODevice::writeData</a>().</p> <!-- @@@writeData --> </div> </div> </div> </div> <div class="ft"> <span></span> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2013 Digia Plc 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> Digia, Qt and their respective logos are trademarks of Digia Plc 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> <script src="scripts/functions.js" type="text/javascript"></script> </body> </html>