clockUtils
1.1
|
class for sockets using udp More...
#include <UdpSocket.h>
Public Types | |
typedef std::function< void(std::vector< uint8_t > packet, std::string ip, uint16_t port, ClockError err)> | packetCallback |
this function type is used receiving a packet using receiveCallback and is called for every packet More... | |
Public Member Functions | |
UdpSocket () | |
constructor More... | |
~UdpSocket () | |
destructor, closes socket if not happened before More... | |
ClockError | bind (uint16_t port) |
binds this socket to the given port for message receiving More... | |
void | close () |
closes a connection if socket is connected More... | |
ClockError | writePacket (IPv4 ip, uint16_t port, const void *str, const size_t length) |
sends a packet being able to be completely received in one call of receivePacket More... | |
ClockError | writePacket (IPv4 ip, uint16_t port, const std::vector< uint8_t > &vec) |
sends a packet being able to be completely received in one call of receivePacket More... | |
ClockError | writePacket (IPv4 ip, uint16_t port, const std::string &str) |
sends a packet being able to be completely received in one call of receivePacket More... | |
ClockError | writePacketAsync (IPv4 ip, uint16_t port, const void *str, const size_t length) |
sends a packet asynchronous being able to be completely received in one call of receivePacket More... | |
ClockError | writePacketAsync (IPv4 ip, uint16_t port, const std::vector< uint8_t > &vec) |
sends a packet asynchronous being able to be completely received in one call of receivePacket More... | |
ClockError | writePacketAsync (IPv4 ip, uint16_t port, const std::string &str) |
sends a packet asynchronous being able to be completely received in one call of receivePacket More... | |
ClockError | write (IPv4 ip, uint16_t port, const void *str, size_t length) |
sends a packet, doesn't work with receivePacket More... | |
ClockError | write (IPv4 ip, uint16_t port, const std::vector< uint8_t > &vec) |
sends a packet, doesn't work with receivePacket More... | |
ClockError | write (IPv4 ip, uint16_t port, const std::string &str) |
sends a packet, doesn't work with receivePacket More... | |
ClockError | writeAsync (IPv4 ip, uint16_t port, const void *str, size_t length) |
sends a message asynchronous, doesn't work with receivePacket More... | |
ClockError | writeAsync (IPv4 ip, uint16_t port, const std::vector< uint8_t > &vec) |
sends a message asynchronous, doesn't work with receivePacket More... | |
ClockError | writeAsync (IPv4 ip, uint16_t port, const std::string &str) |
sends a message asynchronous, doesn't work with receivePacket More... | |
template<typename... T> | |
ClockError | writePacketToIP (const std::string &ip, uint16_t port, T... data) |
sends a packet being able to be completely received in one call of receivePacket More... | |
template<typename... T> | |
ClockError | writePacketToIPAsync (const std::string &ip, uint16_t port, T... data) |
sends a packet asynchronous being able to be completely received in one call of receivePacket More... | |
template<typename... T> | |
ClockError | writeToIP (const std::string &ip, uint16_t port, T... data) |
sends a packet, doesn't work with receivePacket More... | |
template<typename... T> | |
ClockError | writeToIPAsync (const std::string &ip, uint16_t port, T... data) |
sends a message asynchronous, doesn't work with receivePacket More... | |
template<typename... T> | |
ClockError | writePacketToHostname (const std::string &hostname, uint16_t port, T... data) |
sends a packet being able to be completely received in one call of receivePacket More... | |
template<typename... T> | |
ClockError | writePacketToHostnameAsync (const std::string &hostname, uint16_t port, T... data) |
sends a packet asynchronous being able to be completely received in one call of receivePacket More... | |
template<typename... T> | |
ClockError | writeToHostname (const std::string &hostname, uint16_t port, T... data) |
sends a packet, doesn't work with receivePacket More... | |
template<typename... T> | |
ClockError | writeToHostnameAsync (const std::string &hostname, uint16_t port, T... data) |
sends a message asynchronous, doesn't work with receivePacket More... | |
ClockError | receivePacket (std::vector< uint8_t > &buffer, std::string &ip, uint16_t &port) |
receives a packet sent with writePacket, doesn't work with write this functions blocks until a packet is received More... | |
ClockError | receivePacket (std::string &buffer, std::string &ip, uint16_t &port) |
receives a packet sent with writePacket, doesn't work with write More... | |
ClockError | receiveCallback (packetCallback pcb) |
calls the callback for every packet that is received on this socket This function will return immediately More... | |
template<class Container > | |
ClockError | read (Container &buffer, std::string &ip, uint16_t &port) |
receives data on the socket More... | |
Public Attributes | |
const size_t | MAX_PACKET_SIZE |
maximum size one packet is allowed to have, otherwise it can't be sent More... | |
class for sockets using udp
Definition at line 74 of file UdpSocket.h.
typedef std::function<void(std::vector<uint8_t> packet, std::string ip, uint16_t port, ClockError err)> clockUtils::sockets::UdpSocket::packetCallback |
this function type is used receiving a packet using receiveCallback and is called for every packet
Definition at line 79 of file UdpSocket.h.
clockUtils::sockets::UdpSocket::UdpSocket | ( | ) |
constructor
clockUtils::sockets::UdpSocket::~UdpSocket | ( | ) |
destructor, closes socket if not happened before
ClockError clockUtils::sockets::UdpSocket::bind | ( | uint16_t | port | ) |
binds this socket to the given port for message receiving
void clockUtils::sockets::UdpSocket::close | ( | ) |
closes a connection if socket is connected
|
inline |
receives data on the socket
Definition at line 286 of file UdpSocket.h.
ClockError clockUtils::sockets::UdpSocket::receiveCallback | ( | packetCallback | pcb | ) |
calls the callback for every packet that is received on this socket This function will return immediately
ClockError clockUtils::sockets::UdpSocket::receivePacket | ( | std::vector< uint8_t > & | buffer, |
std::string & | ip, | ||
uint16_t & | port | ||
) |
receives a packet sent with writePacket, doesn't work with write this functions blocks until a packet is received
[out] | buffer | The data is stored in this buffer. Old data in this vector is deleted. Enough memory is allocated automatically. |
[out] | ip | The IP of the sender |
[out] | port | The port of the sender |
ClockError clockUtils::sockets::UdpSocket::receivePacket | ( | std::string & | buffer, |
std::string & | ip, | ||
uint16_t & | port | ||
) |
receives a packet sent with writePacket, doesn't work with write
[out] | buffer | The data is stored in this buffer. Old data in this string is deleted. Enough memory is allocated automatically. |
[out] | ip | The IP of the sender |
[out] | port | The port of the sender |
ClockError clockUtils::sockets::UdpSocket::write | ( | IPv4 | ip, |
uint16_t | port, | ||
const void * | str, | ||
size_t | length | ||
) |
sends a packet, doesn't work with receivePacket
|
inline |
sends a packet, doesn't work with receivePacket
Definition at line 156 of file UdpSocket.h.
|
inline |
sends a packet, doesn't work with receivePacket
Definition at line 164 of file UdpSocket.h.
ClockError clockUtils::sockets::UdpSocket::writeAsync | ( | IPv4 | ip, |
uint16_t | port, | ||
const void * | str, | ||
size_t | length | ||
) |
sends a message asynchronous, doesn't work with receivePacket
ClockError clockUtils::sockets::UdpSocket::writeAsync | ( | IPv4 | ip, |
uint16_t | port, | ||
const std::vector< uint8_t > & | vec | ||
) |
sends a message asynchronous, doesn't work with receivePacket
|
inline |
sends a message asynchronous, doesn't work with receivePacket
Definition at line 184 of file UdpSocket.h.
ClockError clockUtils::sockets::UdpSocket::writePacket | ( | IPv4 | ip, |
uint16_t | port, | ||
const void * | str, | ||
const size_t | length | ||
) |
sends a packet being able to be completely received in one call of receivePacket
ClockError clockUtils::sockets::UdpSocket::writePacket | ( | IPv4 | ip, |
uint16_t | port, | ||
const std::vector< uint8_t > & | vec | ||
) |
sends a packet being able to be completely received in one call of receivePacket
|
inline |
sends a packet being able to be completely received in one call of receivePacket
Definition at line 122 of file UdpSocket.h.
ClockError clockUtils::sockets::UdpSocket::writePacketAsync | ( | IPv4 | ip, |
uint16_t | port, | ||
const void * | str, | ||
const size_t | length | ||
) |
sends a packet asynchronous being able to be completely received in one call of receivePacket
ClockError clockUtils::sockets::UdpSocket::writePacketAsync | ( | IPv4 | ip, |
uint16_t | port, | ||
const std::vector< uint8_t > & | vec | ||
) |
sends a packet asynchronous being able to be completely received in one call of receivePacket
|
inline |
sends a packet asynchronous being able to be completely received in one call of receivePacket
Definition at line 142 of file UdpSocket.h.
|
inline |
sends a packet being able to be completely received in one call of receivePacket
Definition at line 228 of file UdpSocket.h.
|
inline |
sends a packet asynchronous being able to be completely received in one call of receivePacket
Definition at line 237 of file UdpSocket.h.
|
inline |
sends a packet being able to be completely received in one call of receivePacket
Definition at line 192 of file UdpSocket.h.
|
inline |
sends a packet asynchronous being able to be completely received in one call of receivePacket
Definition at line 201 of file UdpSocket.h.
|
inline |
sends a packet, doesn't work with receivePacket
Definition at line 246 of file UdpSocket.h.
|
inline |
sends a message asynchronous, doesn't work with receivePacket
Definition at line 255 of file UdpSocket.h.
|
inline |
sends a packet, doesn't work with receivePacket
Definition at line 210 of file UdpSocket.h.
|
inline |
sends a message asynchronous, doesn't work with receivePacket
Definition at line 219 of file UdpSocket.h.
const size_t clockUtils::sockets::UdpSocket::MAX_PACKET_SIZE |
maximum size one packet is allowed to have, otherwise it can't be sent
Definition at line 84 of file UdpSocket.h.