Interface for a datagram based protocol.
More...
#include <datagramsocket.h>
List of all members.
Public Member Functions |
virtual bool | joinMulticastGroup (const NetworkLayerAddress &groupAddress)=0 |
| Join the multicast group specified in groupAddress .
|
virtual bool | leaveMulticastGroup (const NetworkLayerAddress &groupAddress)=0 |
| Leave the multicast group specified in groupAddress .
|
virtual bool | write (const void *pData, size_t &length, const NetworkLayerAddress &destinationAddress, uint16_t destinationPort)=0 |
| Sends data to a specified destination.
|
virtual bool | getAvailableDataLength (size_t &length, bool &available)=0 |
| This function can be used to check if data is available, and if so, how many bytes are in the first packet.
|
virtual bool | read (void *pBuffer, size_t &bufferSize)=0 |
| Store the data of an available packet in the specified buffer.
|
virtual const NetworkLayerAddress * | getLastSourceAddress () const =0 |
| Returns the source address of the last packet which was read.
|
virtual uint16_t | getLastSourcePort () const =0 |
| Returns the source port of the last packet which was read.
|
virtual const NetworkLayerAddress * | getLastDestinationAddress () const =0 |
| Returns the destination address which was stored in the last read packet.
|
Protected Member Functions |
| DatagramSocket () |
| Create an unnamed instance.
|
| DatagramSocket (const std::string &objName) |
| Create an instance with the object name set to objName .
|
Detailed Description
Constructor & Destructor Documentation
nut::DatagramSocket::DatagramSocket |
( |
| ) |
[inline, protected] |
nut::DatagramSocket::DatagramSocket |
( |
const std::string & |
objName | ) |
[inline, protected] |
Member Function Documentation
virtual bool nut::DatagramSocket::getAvailableDataLength |
( |
size_t & |
length, |
|
|
bool & |
available |
|
) |
| [pure virtual] |
This function can be used to check if data is available, and if so, how many bytes are in the first packet.
- Parameters:
-
length | The length of the first available packet (can be zero!). |
available | Flag indicating if a packet is available. |
- Warning:
- The meaning of the length field can differ from platform to platform. With UDP sockets for example, on a Unix-like platform this call will typically set the length to the length of the first UDP packet that can be read. On a Windows platform the behavior is a bit different: there the total length of all the queued messages is stored. This means that you can use the length returned to allocate a buffer, but that you MUST check the length set by the DatagramSocket::read call to verify how many bytes have actually been stored in the buffer.
virtual const NetworkLayerAddress* nut::DatagramSocket::getLastDestinationAddress |
( |
| ) |
const [pure virtual] |
Returns the destination address which was stored in the last read packet. If not supported on the current platform or if this feature was not requested, the function will return NULL. This function can be useful when the packet was sent to a multicast or broadcast address.
virtual const NetworkLayerAddress* nut::DatagramSocket::getLastSourceAddress |
( |
| ) |
const [pure virtual] |
virtual uint16_t nut::DatagramSocket::getLastSourcePort |
( |
| ) |
const [pure virtual] |
virtual bool nut::DatagramSocket::joinMulticastGroup |
( |
const NetworkLayerAddress & |
groupAddress | ) |
[pure virtual] |
virtual bool nut::DatagramSocket::leaveMulticastGroup |
( |
const NetworkLayerAddress & |
groupAddress | ) |
[pure virtual] |
virtual bool nut::DatagramSocket::read |
( |
void * |
pBuffer, |
|
|
size_t & |
bufferSize |
|
) |
| [pure virtual] |
Store the data of an available packet in the specified buffer.
- Parameters:
-
pBuffer | Buffer to store the data in. |
bufferSize | Initially, this should contain the size of the buffer. After completion, this contains the actual number of bytes stored. |
virtual bool nut::DatagramSocket::write |
( |
const void * |
pData, |
|
|
size_t & |
length, |
|
|
const NetworkLayerAddress & |
destinationAddress, |
|
|
uint16_t |
destinationPort |
|
) |
| [pure virtual] |
This function sends a certain amount of data to a specific address and port.
- Parameters:
-
pData | Data to be written. |
length | This parameter should contain the length of the data to be sent. When the function returns, this value will be set to the actual amount of data written. |
destinationAddress | Network address of the destination. |
destinationPort | Destination port number. |
The documentation for this class was generated from the following file: