42 #ifndef QABSTRACTSOCKET_H 43 #define QABSTRACTSOCKET_H 45 #include <QtCore/qiodevice.h> 46 #include <QtCore/qobject.h> 47 #ifndef QT_NO_DEBUG_STREAM 48 #include <QtCore/qdebug.h> 58 #ifndef QT_NO_NETWORKPROXY 72 UnknownSocketType = -1
77 UnknownNetworkLayerProtocol = -1
100 UnknownSocketError = -1
112 Idle = UnconnectedState,
113 HostLookup = HostLookupState,
114 Connecting = ConnectingState,
115 Connected = ConnectedState,
116 Closing = ClosingState,
117 Connection = ConnectedState
124 MulticastLoopbackOption
131 void connectToHost(
const QString &hostName,
quint16 port, OpenMode mode = ReadWrite);
133 void disconnectFromHost();
135 bool isValid()
const;
149 qint64 readBufferSize()
const;
150 void setReadBufferSize(
qint64 size);
155 int socketDescriptor()
const;
156 bool setSocketDescriptor(
int socketDescriptor,
SocketState state = ConnectedState,
157 OpenMode openMode = ReadWrite);
175 bool waitForConnected(
int msecs = 30000);
178 bool waitForDisconnected(
int msecs = 30000);
180 #ifndef QT_NO_NETWORKPROXY 191 #ifndef QT_NO_NETWORKPROXY 196 void connectToHostImplementation(
const QString &hostName,
quint16 port, OpenMode mode = ReadWrite);
197 void disconnectFromHostImplementation();
206 void setLocalPort(
quint16 port);
208 void setPeerPort(
quint16 port);
227 ErrConnectionRefused = ConnectionRefusedError,
228 ErrHostNotFound = HostNotFoundError,
229 ErrSocketRead = UnknownSocketError
231 inline QT3_SUPPORT
int socket()
const {
return socketDescriptor(); }
232 inline QT3_SUPPORT
void setSocket(
int socket) { setSocketDescriptor(socket); }
233 inline QT3_SUPPORT
qulonglong waitForMore(
int msecs,
bool *timeout = 0)
const 238 if (
error() == SocketTimeoutError && timeout)
251 #ifndef QT_NO_DEBUG_STREAM 260 #endif // QABSTRACTSOCKET_H The QVariant class acts like a union for the most common Qt data types.
The QDebug class provides an output stream for debugging information.
#define QT_END_NAMESPACE
This macro expands to.
SocketType
This enum describes the transport layer protocol.
bool waitForReadyRead(int msecs=30000)
This function blocks until new data is available for reading and the QIODevice::readyRead() signal ha...
virtual bool waitForReadyRead(int msecs)
Blocks until new data is available for reading and the readyRead() signal has been emitted...
virtual void close()
First emits aboutToClose(), then closes the device and sets its OpenMode to NotOpen.
virtual qint64 writeData(const char *data, qint64 len)=0
Writes up to maxSize bytes from data to the device.
SocketOption
This enum represents the options that can be set on a socket.
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
#define Q_PRIVATE_SLOT(d, signature)
NetworkLayerProtocol
This enum describes the network layer protocol values used in Qt.
The QString class provides a Unicode character string.
The QObject class is the base class of all Qt objects.
virtual bool atEnd() const
Returns true if the current read and write position is at the end of the device (i.e.
virtual qint64 readLineData(char *data, qint64 maxlen)
Reads up to maxSize characters into data and returns the number of characters read.
SocketState
This enum describes the different states in which a socket can be.
The QNetworkProxy class provides a network layer proxy.
virtual qint64 bytesToWrite() const
For buffered devices, this function returns the number of bytes waiting to be written.
#define QT_BEGIN_NAMESPACE
This macro expands to.
static QIntfbScreen * connected
SocketError
This enum describes the socket errors that can occur.
static const char * data(const QByteArray &arr)
The QHostInfo class provides static functions for host name lookups.
The QAuthenticator class provides an authentication object.
virtual bool isSequential() const
Returns true if this device is sequential; otherwise returns false.
virtual qint64 readData(char *data, qint64 maxlen)=0
Reads up to maxSize bytes from the device into data, and returns the number of bytes read or -1 if an...
virtual qint64 bytesAvailable() const
Returns the number of bytes that are available for reading.
virtual bool waitForBytesWritten(int msecs)
For buffered devices, this function waits until a payload of buffered written data has been written t...
Q_CORE_EXPORT QTextStream & flush(QTextStream &s)
#define Q_DECLARE_PRIVATE(Class)
virtual bool canReadLine() const
Returns true if a complete line of data can be read from the device; otherwise returns false...
The QHostAddress class provides an IP address.
The QIODevice class is the base interface class of all I/O devices in Qt.
The QAbstractSocket class provides the base functionality common to all socket types.
Q_NETWORK_EXPORT QDebug operator<<(QDebug, QAbstractSocket::SocketError)