42 #include "private/qpacketprotocol_p.h" 45 #include <QElapsedTimer> 49 #define MAX_PACKET_SIZE 0x7FFFFFFF 170 bool gotPackets =
false;
199 inProgressSize -=
sizeof(
qint32);
268 if(max > (
signed)
sizeof(
qint32))
304 qint32 sendSize32 = sendSize;
351 return timeout < 0 ? 0 : timeout;
575 #include <qpacketprotocol.moc>
static double elapsed(qint64 after, qint64 before)
#define QT_END_NAMESPACE
This macro expands to.
virtual bool waitForReadyRead(int msecs)
Blocks until new data is available for reading and the readyRead() signal has been emitted...
virtual ~QPacketAutoSend()
virtual ~QPacketProtocol()
Destroys the QPacketProtocol instance.
QByteArray & append(char c)
Appends the character ch to this byte array.
static int qt_timeout_value(int msecs, int elapsed)
bool open(OpenMode openMode)
Reimplemented Function
The QByteArray class provides an array of bytes.
void close()
Reimplemented Function
The QPacketProtocol class encapsulates communicating discrete packets across fragmented IO channels...
QPacketAutoSend send()
Returns a streamable object that is transmitted on destruction.
int count(const T &t) const
Returns the number of occurrences of value in the list.
The QBuffer class provides a QIODevice interface for a QByteArray.
void bytesWritten(qint64 bytes)
The QObject class is the base class of all Qt objects.
void setBuffer(QByteArray *a)
Makes QBuffer uses the QByteArray pointed to by byteArray as its internal buffer. ...
The QElapsedTimer class provides a fast way to calculate elapsed times.
The QPacket class encapsulates an unfragmentable packet of data to be transmitted by QPacketProtocol...
qint64 elapsed() const
Returns the number of milliseconds since this QElapsedTimer was last started.
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
void setVersion(int)
Sets the version number of the data serialization format to v.
bool waitForReadyRead(int msecs=3000)
This function locks until a new packet is available for reading and the QIODevice::readyRead() signal...
qint64 read(char *data, qint64 maxlen)
Reads at most maxSize bytes from the device into data, and returns the number of bytes read...
void append(const T &t)
Inserts value at the end of the list.
#define QT_BEGIN_NAMESPACE
This macro expands to.
qint32 setMaximumPacketSize(qint32)
Sets the maximum allowable packet size to max.
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
QPacketAutoSend(QPacketProtocol *)
const T & at(int i) const
Returns the item at index position i in the list.
QByteArray data() const
Returns raw packet data.
void removeFirst()
Removes the first item in the list.
void clear()
Removes all items from the list.
QPacketProtocolPrivate * d
void clear()
Discard any unread packets.
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
void clear()
Clears data in the packet.
QPacket()
Constructs an empty write-only packet.
OpenMode openMode() const
Returns the mode in which the device has been opened; i.e.
QList< QByteArray > packets
qint64 packetsAvailable() const
Returns the number of received packets yet to be read.
QObject * parent() const
Returns a pointer to the parent object.
virtual qint64 bytesAvailable() const
Returns the number of bytes that are available for reading.
int size() const
Returns the number of bytes in this byte array.
bool isEmpty() const
Returns true if this packet is empty - that is, contains no data.
qint32 maximumPacketSize() const
Returns the maximum packet size allowed.
void setDevice(QIODevice *)
void QDataStream::setDevice(QIODevice *d)
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
The QDataStream class provides serialization of binary data to a QIODevice.
QList< qint64 > sendingPackets
QPacket read()
Return the next unread packet, or an invalid QPacket instance if no packets are available.
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
QPacketProtocolPrivate(QPacketProtocol *parent, QIODevice *_dev)
QIODevice * device()
Return the QIODevice passed to the QPacketProtocol constructor.
The QIODevice class is the base interface class of all I/O devices in Qt.
virtual ~QPacket()
Destroys the QPacket instance.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
void start()
Starts this timer.
QPacketProtocol(QIODevice *dev, QObject *parent=0)
Construct a QPacketProtocol instance that works on dev with the specified parent. ...
void clear()
Clears the contents of the byte array and makes it empty.