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

Public Member Functions

int GetErrNo () const
 
void SetReadAttempt (int n)
 
virtual bool Connect (const char *server, unsigned port, int rcvbuf)
 
virtual bool SendData (const char *buf, size_t size)
 
virtual size_t ReceiveData (void *buf, size_t n)
 
virtual void Disconnect ()
 
virtual bool IsValid () const
 
int Listen (timeval *timeout)
 
net_socket_t GetHandle () const
 
std::string GetHostAddrInfo ()
 
- Public Member Functions inherited from NSROOT::NetSocket
void SetTimeout (timeval timeout)
 

Static Public Member Functions

static const char * GetMyHostName ()
 

Protected Attributes

net_socket_t m_socket
 
int m_rcvbuf
 
int m_errno
 
int m_attempt
 
- Protected Attributes inherited from NSROOT::NetSocket
struct timeval m_timeout
 

Private Member Functions

 TcpSocket (const TcpSocket &)
 
TcpSocketoperator= (const TcpSocket &)
 

Private Attributes

char * m_buffer
 
char * m_bufptr
 
size_t m_buflen
 
size_t m_rcvlen
 

Friends

class TcpServerSocket
 

Detailed Description

Definition at line 66 of file socket.h.

Member Function Documentation

◆ Connect()

bool TcpSocket::Connect ( const char *  server,
unsigned  port,
int  rcvbuf 
)
virtual

Try to connect the socket to an address name, port.

Parameters
serverthe destination address name
portthe destination port
rcvbufthe size of read buffer, else 0 for SOCKET_RCVBUF_MINSIZE
Returns
true on success, else false

Reimplemented in NSROOT::SecureSocket.

Definition at line 189 of file socket.cpp.

◆ Disconnect()

void TcpSocket::Disconnect ( )
virtual

Gracefully disconnect the socket.

Reimplemented in NSROOT::SecureSocket.

Definition at line 411 of file socket.cpp.

◆ GetErrNo()

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

Definition at line 76 of file socket.h.

◆ GetHandle()

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

Definition at line 131 of file socket.h.

◆ GetHostAddrInfo()

std::string TcpSocket::GetHostAddrInfo ( )
Returns
the address string of this host

Definition at line 462 of file socket.cpp.

◆ GetMyHostName()

const char * TcpSocket::GetMyHostName ( )
static
Returns
this host name

Definition at line 481 of file socket.cpp.

◆ IsValid()

bool TcpSocket::IsValid ( ) const
virtual
Returns
true when socket is connected, else false

Reimplemented in NSROOT::SecureSocket.

Definition at line 439 of file socket.cpp.

Referenced by NSROOT::TcpServerSocket::AcceptConnection().

Here is the caller graph for this function:

◆ Listen()

int TcpSocket::Listen ( timeval *  timeout)

Check for read readiness. It returns -1 for errors, 0 for occurred timeout, and >0 when incoming data are ready to read.

Parameters
timeout
Returns
an int for status

Definition at line 444 of file socket.cpp.

◆ ReceiveData()

size_t TcpSocket::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.

Reimplemented in NSROOT::SecureSocket.

Definition at line 318 of file socket.cpp.

◆ SendData()

bool TcpSocket::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.

Reimplemented in NSROOT::SecureSocket.

Definition at line 244 of file socket.cpp.

◆ SetReadAttempt()

void NSROOT::TcpSocket::SetReadAttempt ( int  n)
inline

Configure the number of timed out attempt reading the socket before returning.

Parameters
nthe number of attempt

Definition at line 83 of file socket.h.

Referenced by NSROOT::TcpServerSocket::AcceptConnection().

Here is the caller graph for this function:

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