libhomegear-base  0.7
Base library for Homegear and Homegear family modules.
BaseLib::UdpSocket Class Reference

#include <UdpSocket.h>

Public Member Functions

 UdpSocket (BaseLib::SharedObjects *baseLib)
 
 UdpSocket (BaseLib::SharedObjects *baseLib, std::string listenPort)
 
 UdpSocket (BaseLib::SharedObjects *baseLib, std::string hostname, std::string port)
 
 UdpSocket (BaseLib::SharedObjects *baseLib, std::string hostname, std::string port, std::string listenPort)
 
virtual ~UdpSocket ()
 
void setReadTimeout (int64_t timeout)
 
void setAutoConnect (bool autoConnect)
 
void setHostname (std::string hostname)
 
void setPort (std::string port)
 
std::string getClientIp ()
 
std::string getListenIp ()
 
uint16_t getListenPort ()
 
bool isOpen ()
 
int32_t proofread (char *buffer, int32_t bufferSize, std::string &senderIp)
 Reads bytes from UDP socket into "buffer". More...
 
int32_t proofwrite (const std::shared_ptr< std::vector< char >> &data)
 
int32_t proofwrite (const std::vector< char > &data)
 
int32_t proofwrite (const std::string &data)
 
int32_t proofwrite (const char *buffer, int32_t bytesToWrite)
 
void open ()
 
void close ()
 

Protected Member Functions

void getSocketDescriptor ()
 
void getConnection ()
 
void autoConnect ()
 

Protected Attributes

BaseLib::SharedObjects_bl = nullptr
 
int64_t _readTimeout = 15000000
 
bool _autoConnect = true
 
std::string _hostname
 
std::string _clientIp
 
std::string _port
 
std::string _listenIp
 
uint16_t _listenPort = 0
 
struct addrinfo * _serverInfo = nullptr
 
std::mutex _readMutex
 
std::mutex _writeMutex
 
std::shared_ptr< FileDescriptor_socketDescriptor
 

Constructor & Destructor Documentation

§ UdpSocket() [1/4]

BaseLib::UdpSocket::UdpSocket ( BaseLib::SharedObjects baseLib)

§ UdpSocket() [2/4]

BaseLib::UdpSocket::UdpSocket ( BaseLib::SharedObjects baseLib,
std::string  listenPort 
)

§ UdpSocket() [3/4]

BaseLib::UdpSocket::UdpSocket ( BaseLib::SharedObjects baseLib,
std::string  hostname,
std::string  port 
)

§ UdpSocket() [4/4]

BaseLib::UdpSocket::UdpSocket ( BaseLib::SharedObjects baseLib,
std::string  hostname,
std::string  port,
std::string  listenPort 
)

§ ~UdpSocket()

BaseLib::UdpSocket::~UdpSocket ( )
virtual

Member Function Documentation

§ autoConnect()

void BaseLib::UdpSocket::autoConnect ( )
protected

§ close()

void BaseLib::UdpSocket::close ( )

§ getClientIp()

std::string BaseLib::UdpSocket::getClientIp ( )
inline

§ getConnection()

void BaseLib::UdpSocket::getConnection ( )
protected

§ getListenIp()

std::string BaseLib::UdpSocket::getListenIp ( )
inline

§ getListenPort()

uint16_t BaseLib::UdpSocket::getListenPort ( )
inline

§ getSocketDescriptor()

void BaseLib::UdpSocket::getSocketDescriptor ( )
protected

§ isOpen()

bool BaseLib::UdpSocket::isOpen ( )

§ open()

void BaseLib::UdpSocket::open ( )

§ proofread()

int32_t BaseLib::UdpSocket::proofread ( char *  buffer,
int32_t  bufferSize,
std::string &  senderIp 
)

Reads bytes from UDP socket into "buffer".

Parameters
[in]bufferThe char array to write received bytes into.
[in]bufferSizeThe size of the buffer.
[out]senderIpThe IP the packet was received from.
Returns
Returns the number of bytes written into "buffer". Never returns 0 or a negative number.
Exceptions
SocketTimeOutExceptionThrown on timeout.
SocketClosedExceptionThrown when socket was closed.
SocketOperationExceptionThrown when socket is nullptr.

§ proofwrite() [1/4]

int32_t BaseLib::UdpSocket::proofwrite ( const std::shared_ptr< std::vector< char >> &  data)

§ proofwrite() [2/4]

int32_t BaseLib::UdpSocket::proofwrite ( const std::vector< char > &  data)

§ proofwrite() [3/4]

int32_t BaseLib::UdpSocket::proofwrite ( const std::string &  data)

§ proofwrite() [4/4]

int32_t BaseLib::UdpSocket::proofwrite ( const char *  buffer,
int32_t  bytesToWrite 
)

§ setAutoConnect()

void BaseLib::UdpSocket::setAutoConnect ( bool  autoConnect)
inline

§ setHostname()

void BaseLib::UdpSocket::setHostname ( std::string  hostname)
inline

§ setPort()

void BaseLib::UdpSocket::setPort ( std::string  port)
inline

§ setReadTimeout()

void BaseLib::UdpSocket::setReadTimeout ( int64_t  timeout)
inline

Member Data Documentation

§ _autoConnect

bool BaseLib::UdpSocket::_autoConnect = true
protected

§ _bl

BaseLib::SharedObjects* BaseLib::UdpSocket::_bl = nullptr
protected

§ _clientIp

std::string BaseLib::UdpSocket::_clientIp
protected

§ _hostname

std::string BaseLib::UdpSocket::_hostname
protected

§ _listenIp

std::string BaseLib::UdpSocket::_listenIp
protected

§ _listenPort

uint16_t BaseLib::UdpSocket::_listenPort = 0
protected

§ _port

std::string BaseLib::UdpSocket::_port
protected

§ _readMutex

std::mutex BaseLib::UdpSocket::_readMutex
protected

§ _readTimeout

int64_t BaseLib::UdpSocket::_readTimeout = 15000000
protected

§ _serverInfo

struct addrinfo* BaseLib::UdpSocket::_serverInfo = nullptr
protected

§ _socketDescriptor

std::shared_ptr<FileDescriptor> BaseLib::UdpSocket::_socketDescriptor
protected

§ _writeMutex

std::mutex BaseLib::UdpSocket::_writeMutex
protected

The documentation for this class was generated from the following files: