#include <TcpSocketBuffer.h> [code]
Inherits Protocols::Generics::SocketBuffer.
Inheritance diagram for Protocols::Generics::TcpSocketBuffer:


Depending on the type of socket (stream or datagram) that is used by a SocketTransport object different buffering strategies should be applied. In some case, in order to abstract the differences between stream and datagram transports, some modifications of the buffered data (e.g. adding a length field to the header when the transport is TCP, see eDonkey).
Definition at line 45 of file TcpSocketBuffer.h.
Public Member Functions | |
| TcpSocketBuffer (int readBufferSize, int writeBufferSize) | |
| Constructs a TcpSocketBuffer object. | |
| ~TcpSocketBuffer () | |
| Destructs an object. | |
| bool | canRead (int count) const |
| Tells whether count bytes can be read from the read buffer. | |
| QByteArray | peek (int count) const |
| Peeks count bytes from the read buffer. | |
| QByteArray | peekAtMost (int count) const |
| Peeks at most count bytes from the read buffer. | |
| QByteArray | peekTo (const QByteArray &delimiter) const |
| Peeks from the buffer all bytes up to and including delimiter. | |
| QByteArray | peekAll () const |
| Peeks all bytes from the read buffer. | |
| QByteArray | read (int count) |
| Reads count bytes from the read buffer. | |
| QByteArray | readAtMost (int count) |
| Reads at most count bytes from the read buffer. | |
| QByteArray | readTo (const QByteArray &delimiter) |
| Extracts from the buffer all bytes up to and including delimiter. | |
| QByteArray | readAll () |
| Extracts and returns all bytes from the read buffer. | |
| bool | canWrite (int count) const |
| Tells whether count number of bytes can be buffered in the write buffer. | |
| bool | write (const QByteArray &bytes, bool flush=true) |
| Writes bytes to the write buffer. | |
| void | tryReadFrom (Socket *socket) |
| Tries to read from the socket to the read buffer. | |
| void | tryWriteTo (Socket *socket) |
| Tries to write from the buffered write buffer to socket. | |
Private Member Functions | |
| CALITKO_TESTABLE | TcpSocketBuffer (const TcpSocketBuffer &) |
| TcpSocketBuffer & | operator= (const TcpSocketBuffer &) |
| void | peek (char *destination, int size) const |
| Copies the first bytes from the read buffer in outBytes. | |
| void | purgeReadBuffer (int count) |
| Purges the first count bytes from the read buffer. | |
| void | setReadBufferSize (int size) |
| Resets the read buffer size and all previous data is lost. | |
| int | readBufferSize () const |
| int | bytesToRead () const |
| char * | nextReadChunk () const |
| int | nextReadChunkSize () const |
| void | hasRead (int count) |
| Adds count bytes to the end of the read buffer. | |
| void | write (const char *source, int size, bool flush) |
| Buffers size bytes from source in the write buffer. | |
| void | setWriteBufferSize (int size) |
| Resets the write buffer size and all previous data is lost. | |
| int | writeBufferSize () const |
| int | bytesToWrite () const |
| char * | nextWriteChunk () const |
| int | nextWriteChunkSize () const |
| void | hasWritten (int count) |
| Remove count bytes from the beginning of the write buffer. | |
Private Attributes | |
| char * | readBuffer |
| int | readSize |
| int | readStart |
| int | readEnd |
| char * | writeBuffer |
| int | writeSize |
| int | writeStart |
| int | writeEnd |
| int | writeFlushEnd |
|
|
|
|
||||||||||||
|
Constructs a TcpSocketBuffer object.
Definition at line 35 of file TcpSocketBuffer.cpp. |
|
|
Destructs an object.
Definition at line 48 of file TcpSocketBuffer.cpp. |
|
|
Definition at line 317 of file TcpSocketBuffer.cpp. |
|
|
Definition at line 496 of file TcpSocketBuffer.cpp. |
|
|
Tells whether count bytes can be read from the read buffer.
Implements Protocols::Generics::Buffer. Definition at line 223 of file TcpSocketBuffer.cpp. |
|
|
Tells whether count number of bytes can be buffered in the write buffer.
Implements Protocols::Generics::Buffer. Definition at line 416 of file TcpSocketBuffer.cpp. |
|
|
Adds count bytes to the end of the read buffer.
Definition at line 358 of file TcpSocketBuffer.cpp. |
|
|
Remove count bytes from the beginning of the write buffer.
Definition at line 533 of file TcpSocketBuffer.cpp. |
|
|
The number of bytes you can write consequatively to the read buffer starting from the returned raw pointer is returned by nextReadChunkSize().
Definition at line 329 of file TcpSocketBuffer.cpp. |
|
|
Definition at line 339 of file TcpSocketBuffer.cpp. |
|
|
The number of bytes you can read consequatively from the write buffer starting at returned raw pointer is returned by nextWriteChunkSize().
Definition at line 508 of file TcpSocketBuffer.cpp. |
|
|
Definition at line 517 of file TcpSocketBuffer.cpp. |
|
|
|
|
||||||||||||
|
Copies the first bytes from the read buffer in outBytes.
The buffer read position is not moved forward as that will be the case with read().
Definition at line 245 of file TcpSocketBuffer.cpp. |
|
|
Peeks count bytes from the read buffer.
Implements Protocols::Generics::Buffer. Definition at line 66 of file TcpSocketBuffer.cpp. |
|
|
Peeks all bytes from the read buffer.
Implements Protocols::Generics::Buffer. Definition at line 127 of file TcpSocketBuffer.cpp. |
|
|
Peeks at most count bytes from the read buffer.
Implements Protocols::Generics::Buffer. Definition at line 90 of file TcpSocketBuffer.cpp. |
|
|
Peeks from the buffer all bytes up to and including delimiter.
Implements Protocols::Generics::Buffer. Definition at line 110 of file TcpSocketBuffer.cpp. |
|
|
Purges the first count bytes from the read buffer. We implement read(), readTo() and readAll() in terms of peek(), peekTo() and peekAll() and then use purgeReadBuffer() to purge the bytes already extracted by the read functions.
Definition at line 269 of file TcpSocketBuffer.cpp. |
|
|
Reads count bytes from the read buffer.
Implements Protocols::Generics::Buffer. Definition at line 141 of file TcpSocketBuffer.cpp. |
|
|
Extracts and returns all bytes from the read buffer.
Implements Protocols::Generics::Buffer. Definition at line 187 of file TcpSocketBuffer.cpp. |
|
|
Reads at most count bytes from the read buffer.
Implements Protocols::Generics::Buffer. Definition at line 157 of file TcpSocketBuffer.cpp. |
|
|
Definition at line 308 of file TcpSocketBuffer.cpp. |
|
|
Extracts from the buffer all bytes up to and including delimiter.
Implements Protocols::Generics::Buffer. Definition at line 176 of file TcpSocketBuffer.cpp. |
|
|
Resets the read buffer size and all previous data is lost.
Definition at line 292 of file TcpSocketBuffer.cpp. |
|
|
Resets the write buffer size and all previous data is lost.
Definition at line 471 of file TcpSocketBuffer.cpp. |
|
|
Tries to read from the socket to the read buffer.
Implements Protocols::Generics::SocketBuffer. Definition at line 198 of file TcpSocketBuffer.cpp. |
|
|
Tries to write from the buffered write buffer to socket.
Implements Protocols::Generics::SocketBuffer. Definition at line 389 of file TcpSocketBuffer.cpp. |
|
||||||||||||||||
|
Buffers size bytes from source in the write buffer.
The parameter flush will give the buffer a hint how the data should be passed to the transport. The buffer would try to send all bytes written in consequative calls to write() with flush set to false in a single piece to the transport layer. flush may be ignored for stream transports but its use is essential for datagram transports.
Definition at line 443 of file TcpSocketBuffer.cpp. |
|
||||||||||||
|
Writes bytes to the write buffer.
Implements Protocols::Generics::Buffer. Definition at line 376 of file TcpSocketBuffer.cpp. |
|
|
Definition at line 487 of file TcpSocketBuffer.cpp. |
|
|
Definition at line 94 of file TcpSocketBuffer.h. |
|
|
Definition at line 97 of file TcpSocketBuffer.h. |
|
|
Definition at line 95 of file TcpSocketBuffer.h. |
|
|
Definition at line 96 of file TcpSocketBuffer.h. |
|
|
Definition at line 98 of file TcpSocketBuffer.h. |
|
|
Definition at line 101 of file TcpSocketBuffer.h. |
|
|
Definition at line 102 of file TcpSocketBuffer.h. |
|
|
Definition at line 99 of file TcpSocketBuffer.h. |
|
|
Definition at line 100 of file TcpSocketBuffer.h. |