CPPMyth
Library to interoperate with MythTV server
Loading...
Searching...
No Matches
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 size_t BlockingRead (void *buf, size_t n)
virtual void Disconnect ()
virtual bool IsValid () const
int Listen (timeval *timeout)
net_socket_t GetHandle () const
std::string GetRemoteAddrInfo ()
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 &)
TcpSocket & operator= (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.

Constructor & Destructor Documentation

◆ TcpSocket()

TcpSocket::TcpSocket ( )

Definition at line 98 of file socket.cpp.

◆ ~TcpSocket()

TcpSocket::~TcpSocket ( )
virtual

Definition at line 111 of file socket.cpp.

Member Function Documentation

◆ BlockingRead()

size_t TcpSocket::BlockingRead ( void * buf,
size_t n )
virtual

Read data or block.

Parameters
bufthe pointer to write data
nread at most n bytes
Returns
the number of received byte

Reimplemented in NSROOT::SecureSocket.

Definition at line 478 of file socket.cpp.

References IsValid().

◆ 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 256 of file socket.cpp.

References Disconnect(), and IsValid().

◆ Disconnect()

void TcpSocket::Disconnect ( )
virtual

Gracefully disconnect the socket.

Reimplemented in NSROOT::SecureSocket.

Definition at line 503 of file socket.cpp.

References IsValid().

Referenced by Connect().

Here is the caller graph for this function:

◆ 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 139 of file socket.h.

◆ GetHostAddrInfo()

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

Definition at line 578 of file socket.cpp.

References IsValid().

◆ GetMyHostName()

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

Definition at line 597 of file socket.cpp.

◆ GetRemoteAddrInfo()

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

Definition at line 559 of file socket.cpp.

References IsValid().

◆ IsValid()

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

Definition at line 536 of file socket.cpp.

Referenced by NSROOT::TcpServerSocket::AcceptConnection(), BlockingRead(), Connect(), Disconnect(), GetHostAddrInfo(), GetRemoteAddrInfo(), Listen(), ReceiveData(), and SendData().

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 541 of file socket.cpp.

References IsValid().

◆ 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 385 of file socket.cpp.

References IsValid().

◆ 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 311 of file socket.cpp.

References IsValid().

◆ 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:

◆ TcpServerSocket

friend class TcpServerSocket
friend

Definition at line 68 of file socket.h.

Field Documentation

◆ m_attempt

int NSROOT::TcpSocket::m_attempt
protected

Definition at line 160 of file socket.h.

◆ m_buffer

char* NSROOT::TcpSocket::m_buffer
private

Definition at line 163 of file socket.h.

◆ m_buflen

size_t NSROOT::TcpSocket::m_buflen
private

Definition at line 165 of file socket.h.

◆ m_bufptr

char* NSROOT::TcpSocket::m_bufptr
private

Definition at line 164 of file socket.h.

◆ m_errno

int NSROOT::TcpSocket::m_errno
protected

Definition at line 159 of file socket.h.

◆ m_rcvbuf

int NSROOT::TcpSocket::m_rcvbuf
protected

Definition at line 158 of file socket.h.

◆ m_rcvlen

size_t NSROOT::TcpSocket::m_rcvlen
private

Definition at line 166 of file socket.h.

◆ m_socket

net_socket_t NSROOT::TcpSocket::m_socket
protected

Definition at line 157 of file socket.h.


The documentation for this class was generated from the following files:
  • /home/jlb/src/janbar/PVR/cppmythlib/cppmyth/src/private/socket.h
  • /home/jlb/src/janbar/PVR/cppmythlib/cppmyth/src/private/socket.cpp