CPPMyth
Library to interoperate with MythTV server
NSROOT::UdpSocket Class Reference
Inheritance diagram for NSROOT::UdpSocket:
Collaboration diagram for NSROOT::UdpSocket:

Public Member Functions

 UdpSocket (size_t bufferSize)
 
int GetErrNo () const
 
bool SendData (const char *buf, size_t size)
 
size_t ReceiveData (void *buf, size_t n)
 
bool IsValid () const
 
bool Open (SOCKET_AF_t af, const char *target, unsigned port)
 
bool Open (SOCKET_AF_t af, bool broadcast=false)
 
bool SetAddress (const char *target, unsigned port)
 
bool SetMulticastTTL (int multicastTTL)
 
std::string GetRemoteAddrInfo () const
 
net_socket_t GetHandle () const
 
- Public Member Functions inherited from NSROOT::NetSocket
void SetTimeout (timeval timeout)
 

Private Member Functions

 UdpSocket (const UdpSocket &)
 
UdpSocketoperator= (const UdpSocket &)
 

Private Attributes

SocketAddressm_addr
 
SocketAddressm_from
 
net_socket_t m_socket
 
int m_errno
 
char * m_buffer
 
char * m_bufptr
 
size_t m_buflen
 
size_t m_rcvlen
 

Additional Inherited Members

- Protected Attributes inherited from NSROOT::NetSocket
struct timeval m_timeout
 

Detailed Description

Definition at line 224 of file socket.h.

Member Function Documentation

◆ GetErrNo()

int NSROOT::UdpSocket::GetErrNo ( ) const
inline
Returns
the last error occuring on call

Definition at line 234 of file socket.h.

◆ GetHandle()

net_socket_t NSROOT::UdpSocket::GetHandle ( ) const
inline
Returns
the socket handle

Definition at line 298 of file socket.h.

◆ GetRemoteAddrInfo()

std::string UdpSocket::GetRemoteAddrInfo ( ) const
Returns
the address string of the remote host

Definition at line 894 of file socket.cpp.

◆ IsValid()

bool UdpSocket::IsValid ( ) const
Returns
true when socket is opened, else false

Definition at line 889 of file socket.cpp.

◆ Open() [1/2]

bool UdpSocket::Open ( SOCKET_AF_t  af,
const char *  target,
unsigned  port 
)

Open the socket and configure the given destination.

Parameters
afthe protocol
targetthe address name of destination
port
Returns
true on success, else false

Definition at line 686 of file socket.cpp.

◆ Open() [2/2]

bool UdpSocket::Open ( SOCKET_AF_t  af,
bool  broadcast = false 
)

Open the socket.

Parameters
afthe protocol
broadcastenable broadcast permission
Returns
true on success, else false

Definition at line 691 of file socket.cpp.

◆ ReceiveData()

size_t UdpSocket::ReceiveData ( void *  buf,
size_t  n 
)
virtual

Read data from the socket.

Parameters
bufthe pointer to write received data
nthe number of byte to read
Returns
the number of received byte

Implements NSROOT::NetSocket.

Definition at line 822 of file socket.cpp.

◆ SendData()

bool UdpSocket::SendData ( const char *  buf,
size_t  size 
)
virtual

Send data into the socket.

Parameters
bufthe pointer to data
sizethe number of byte to send
Returns
true when succeeded, else false

Implements NSROOT::NetSocket.

Definition at line 805 of file socket.cpp.

◆ SetAddress()

bool UdpSocket::SetAddress ( const char *  target,
unsigned  port 
)

Configure the destination.

Parameters
targetthe address name of destination
port
Returns
true on success, else false

Definition at line 724 of file socket.cpp.

◆ SetMulticastTTL()

bool UdpSocket::SetMulticastTTL ( int  multicastTTL)

Configure hop limit value to be used for multicast packets on the opened socket.

Parameters
multicastTTL
Returns
true on success, else false

Definition at line 766 of file socket.cpp.


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