![]() |
Home · All Classes · Main Classes · Grouped Classes · Modules · Functions | ![]() |
The QLocalSocket class provides a local socket. More...
#include <QLocalSocket>
Inherits QIODevice.
This class was introduced in Qt 4.4.
The QLocalSocket class provides a local socket.
On Windows this is a named pipe and on Unix this this is a local domain socket.
If an error occurs, socketError() returns the type of error, and errorString() can be called to get a human readable description of what happened.
Although QLocalSocket is designed for use with an event loop, it's possible to use it without one. In that case, you must use waitForConnected(), waitForReadyRead(), waitForBytesWritten(), and waitForDisconnected() which blocks until the operation is complete or the timeout expires.
Note that this feature is not supported on Windows CE.
See also QLocalServer.
The LocalServerError enumeration represents the errors that can occur. The most recent error can be retrieved through a call to QLocalSocket::error().
Constant | Value | Description |
---|---|---|
QLocalSocket::ConnectionRefusedError | QAbstractSocket::ConnectionRefusedError | The connection was refused by the peer (or timed out). |
QLocalSocket::PeerClosedError | QAbstractSocket::RemoteHostClosedError | 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. |
QLocalSocket::ServerNotFoundError | QAbstractSocket::HostNotFoundError | The local socket name was not found. |
QLocalSocket::SocketAccessError | QAbstractSocket::SocketAccessError | The socket operation failed because the application lacked the required privileges. |
QLocalSocket::SocketResourceError | QAbstractSocket::SocketResourceError | The local system ran out of resources (e.g., too many sockets). |
QLocalSocket::SocketTimeoutError | QAbstractSocket::SocketTimeoutError | The socket operation timed out. |
QLocalSocket::DatagramTooLargeError | QAbstractSocket::DatagramTooLargeError | The datagram was larger than the operating system's limit (which can be as low as 8192 bytes). |
QLocalSocket::ConnectionError | QAbstractSocket::NetworkError | An error occurred with the connection. |
QLocalSocket::UnsupportedSocketOperationError | QAbstractSocket::UnsupportedSocketOperationError | The requested socket operation is not supported by the local operating system. |
QLocalSocket::UnknownSocketError | QAbstractSocket::UnknownSocketError | An unidentified error occurred. |
This enum describes the different states in which a socket can be.
Constant | Value | Description |
---|---|---|
QLocalSocket::UnconnectedState | QAbstractSocket::UnconnectedState | The socket is not connected. |
QLocalSocket::ConnectingState | QAbstractSocket::ConnectingState | The socket has started establishing a connection. |
QLocalSocket::ConnectedState | QAbstractSocket::ConnectedState | A connection is established. |
QLocalSocket::ClosingState | QAbstractSocket::ClosingState | The socket is about to close (data may still be waiting to be written). |
See also QLocalSocket::state().
Creates a new local socket. The parent argument is passed to QObject's constructor.
Destroys the socket, closing the connection if necessary.
This signal is emitted after connectToServer() has been called and a connection has been successfully established.
See also connectToServer() and disconnected().
This signal is emitted when the socket has been disconnected.
See also connectToServer(), disconnectFromServer(), abort(), and connected().
This is an overloaded member function, provided for convenience.
This signal is emitted after an error occurred. The socketError parameter describes the type of error that occurred.
QLocalSocket::LocalSocketError is not a registered metatype, so for queued connections, you will have to register it with Q_REGISTER_METATYPE.
See also error() and errorString().
Returns the server path that the socket is connected to.
Note: This is platform specific
See also connectToServer() and serverName().
See also setReadBufferSize().
Returns the name of the peer as specified by connectToServer(), or an empty QString if connectToServer() has not been called or it failed.
See also connectToServer() and fullServerName().
See also readBufferSize().
See also socketDescriptor().
See also setSocketDescriptor().
Returns the state of the socket.
See also error().
This signal is emitted whenever QLocalSocket's state changes. The socketState parameter is the new state.
QLocalSocket::SocketState is not a registered metatype, so for queued connections, you will have to register it with Q_REGISTER_METATYPE.
See also state().
Copyright © 2008 Trolltech | Trademarks | Qt 4.4.0 |