A data stream, that can be later send data as at UDP packet or read data from an UDP packet. More...
#include <dashel.h>
Public Member Functions | |
PacketStream (const std::string &protocolName) | |
Constructor. | |
PacketStream (const std::string &protocolName) | |
Constructor. | |
virtual void | receive (IPV4Address &source)=0 |
Receive a packet and make its payload available for reading. | |
virtual void | receive (IPV4Address &source)=0 |
Receive a packet and make its payload available for reading. | |
virtual void | send (const IPV4Address &dest)=0 |
Send all written data to an IP address in a single packet. | |
virtual void | send (const IPV4Address &dest)=0 |
Send all written data to an IP address in a single packet. |
A data stream, that can be later send data as at UDP packet or read data from an UDP packet.
You can use PacketStream to write and read data as with normal stream, with the difference that: written byte will be collected in a send buffer until send() is called with the destination address; if you have written too much byte for send to transmit all of them an exception will occur. However, the underlying operating system may pretend that all data has been transmitted while discarding some of it anyway. In any case, send less bytes than ethernet MTU minus UDP header. you have to call receive() when there are bytes available on the stream to be able to read them; if your read past the received bytes an exception will occur.
Definition at line 378 of file dashel.h.
Dashel::PacketStream::PacketStream | ( | const std::string & | protocolName | ) | [inline] |
Dashel::PacketStream::PacketStream | ( | const std::string & | protocolName | ) | [inline] |
virtual void Dashel::PacketStream::receive | ( | IPV4Address & | source | ) | [pure virtual] |
Receive a packet and make its payload available for reading.
Block until a packet is available.
source | IP address from where the packet originates. |
Implemented in Dashel::UDPSocketStream, and Dashel::UDPSocketStream.
virtual void Dashel::PacketStream::receive | ( | IPV4Address & | source | ) | [pure virtual] |
Receive a packet and make its payload available for reading.
Block until a packet is available.
source | IP address from where the packet originates. |
Implemented in Dashel::UDPSocketStream, and Dashel::UDPSocketStream.
virtual void Dashel::PacketStream::send | ( | const IPV4Address & | dest | ) | [pure virtual] |
Send all written data to an IP address in a single packet.
dest | IP address to send packet to |
Implemented in Dashel::UDPSocketStream, and Dashel::UDPSocketStream.
virtual void Dashel::PacketStream::send | ( | const IPV4Address & | dest | ) | [pure virtual] |
Send all written data to an IP address in a single packet.
dest | IP address to send packet to |
Implemented in Dashel::UDPSocketStream, and Dashel::UDPSocketStream.