A class which allows you to send and receive packets over a TCP connection.
More...
#include <tcppacketsocket.h>
List of all members.
Public Member Functions |
| | TCPPacketSocket (TCPSocket *pSock, bool deleteSocket, bool sixteenBit=false, uint32_t maxReceiveLength=0xffffffff, size_t idLength=0, uint32_t id=0) |
| | Create a socket which can be used to send packets over a TCP connection.
|
|
bool | poll () |
| | This function checks if data is available on the underlying TCP socket and stores all the available packets in an internal queue.
|
| bool | getAvailableDataLength (size_t &length) |
| | Returns the amount of data that is available on the underlying TCP socket.
|
| bool | isPacketAvailable () |
| | This function checks if packets are stored in the internal packet queue.
|
| bool | read (Packet &packet) |
| | Extract the first packet which is stored in the internal queue and store the data in packet.
|
| bool | write (const void *pData, size_t length) |
| | Transmit a packet of length length, containing the data specified in pData.
|
Detailed Description
Constructor & Destructor Documentation
| nut::TCPPacketSocket::TCPPacketSocket |
( |
TCPSocket * |
pSock, |
|
|
bool |
deleteSocket, |
|
|
bool |
sixteenBit = false, |
|
|
uint32_t |
maxReceiveLength = 0xffffffff, |
|
|
size_t |
idLength = 0, |
|
|
uint32_t |
id = 0 |
|
) |
| |
Create a socket which can be used to send packets over a TCP connection. In 16-bit mode, the framing method used is compatible with the one described in RFC 4571.
- Parameters:
-
| pSock | The TCP socket which will be used to send and receive packets. The socket should be in a connected state before attempting to read or write data packets. |
| deleteSocket | If true, the TCP socket will be deleted when the TCPPacketSocket instance is destroyed. |
| sixteenBit | If true, a 16 bit length field will be used in the framing method. Otherwise, a 32 bit length field is used. The length field will be encoded in netword byte order (big endian). |
| maxReceiveLength | Packets containing a length field which exceeds this value will generate an error. |
| idLength | If not zero, this many bytes of the id parameter will also be stored in each packet. Packet reading will fail if the bytes are not present in a packet. |
| id | An optional identifier which can be stored in each packet. |
Member Function Documentation
| bool nut::TCPPacketSocket::getAvailableDataLength |
( |
size_t & |
length | ) |
[inline] |
| bool nut::TCPPacketSocket::isPacketAvailable |
( |
| ) |
[inline] |
This function checks if packets are stored in the internal packet queue. Incoming packets are stored in this queue by calling the TCPPacketSocket::poll function. Packets can be extracted from this queue by calling the TCPPacketSocket::read function.
| bool nut::TCPPacketSocket::read |
( |
Packet & |
packet | ) |
|
Extract the first packet which is stored in the internal queue and store the data in packet. Incoming packets are stored in this queue by calling the TCPPacketSocket::poll function.
| bool nut::TCPPacketSocket::write |
( |
const void * |
pData, |
|
|
size_t |
length |
|
) |
| |
The documentation for this class was generated from the following file: