Nix (Dev) 3.5.10
dev - 3.5.10 - 1af9301
Loading...
Searching...
No Matches
CStreamSocketTmpl< ADDR > Class Template Reference

#include <CStreamSocket.hpp>

Inheritance diagram for CStreamSocketTmpl< ADDR >:
[legend]
Collaboration diagram for CStreamSocketTmpl< ADDR >:
[legend]

Public Types

using addr_t = ADDR
 

Public Member Functions

 CStreamSocketTmpl ()=default
 
 CStreamSocketTmpl (socket_t handle)
 
 CStreamSocketTmpl (CStreamSocket &&sock)
 
 CStreamSocketTmpl (CStreamSocketTmpl &&sock) noexcept
 
CStreamSocketTmploperator= (CStreamSocketTmpl &&rhs) noexcept
 
CStreamSocketTmpl create (int32_t protocol=0)
 
addr_t getAddr () const
 
addr_t getPeerAddr () const
 
ssize_t read (const std::vector< iovec > &ranges)
 
virtual ssize_t read (void *buf, size_t n)
 
virtual ssize_t read_n (void *buf, size_t n)
 
virtual ssize_t write (const std::string &s)
 
virtual ssize_t write (const std::vector< iovec > &ranges)
 
virtual ssize_t write (const void *buf, size_t n)
 
virtual ssize_t write_n (const void *buf, size_t n)
 
virtual bool setReadTimeout (const std::chrono::microseconds &to)
 
template<class Rep , class Period >
bool setReadTimeout (const std::chrono::duration< Rep, Period > &to)
 
virtual bool setWriteTimeout (const std::chrono::microseconds &to)
 
template<class Rep , class Period >
bool write_timeout (const std::chrono::duration< Rep, Period > &to)
 
bool operator! () const
 Operador de negación.
 
 operator bool () const
 Operador de conversión a bool.
 
virtual bool bind (const CSocketAddress &address)
 Asigna una dirección a un socket.
 
bool bind (const sockaddr *address, socklen_t len) const
 
bool isOpen () const
 Comprueba que el handle del socket sea válido.
 
socket_t release ()
 Pone a -1 el handle interno y devuelve el valor anterior. Al no invalidar el file descriptor del socket, se puede usar para desasociar el socket del Sistema Operativo de un objeto CSocket concreto.
 
void reset (socket_t handle=INVALID_SOCKET)
 Asigna un nuevo handle al socket e invalida el anterior.
 
CSocket clone () const
 Crea un nuevo objeto CSocket con el mismo handle que el actual.
 
bool close ()
 Cierra el socket.
 
virtual CSocketAddressAny getAddress () const
 
virtual CSocketAddressAny getPeerAddress () const
 
virtual sa_family_t getFamily () const
 
socket_t getHandle () const
 
void setLastError (int32_t err=INT32_MAX) const
 
std::string getLastErrorString () const
 
void clearLastError (int32_t value=0) const
 
bool getOption (int32_t level, int32_t optName, void *optVal, socklen_t *optLength) const
 
template<typename T >
bool getOption (const int32_t level, const int32_t optName, T *value) const
 
bool setOption (int32_t level, int32_t optName, const void *optVal, socklen_t optLength) const
 
template<typename T >
bool setOption (const int32_t level, const int32_t optName, const T &value)
 
bool setNonBlocking (bool on=true) const
 

Static Public Member Functions

static std::tuple< CStreamSocketTmpl, CStreamSocketTmplpair (int32_t protocol=0)
 
static CStreamSocket create (int32_t domain, int32_t protocol=0)
 
static CSocket create (int32_t domain, int32_t type, int32_t protocol=0)
 
static bool close (socket_t h)
 
static std::tuple< CSocket, CSocketpair (int32_t domain, int32_t type, int32_t protocol=0)
 

Static Public Attributes

static constexpr sa_family_t ADDRESS_FAMILY = ADDR::ADDRESS_FAMILY
 
static constexpr int32_t COMM_TYPE = SOCK_STREAM
 

Protected Member Functions

template<typename T >
checkRet (T ret) const
 
template<typename T >
bool checkRetBool (T ret) const
 
socket_t checkSocket (socket_t ret) const
 
bool checkSocketBool (socket_t ret) const
 
bool closeOnError ()
 

Static Protected Member Functions

static socket_t createHandle (int32_t domain)
 
static int32_t getErrno ()
 Función que devuelve el valor actual de errno.
 

Protected Attributes

socket_t m_handle
 

Private Attributes

int32_t m_lastError
 

Member Typedef Documentation

◆ addr_t

template<typename ADDR >
using CStreamSocketTmpl< ADDR >::addr_t = ADDR

Constructor & Destructor Documentation

◆ CStreamSocketTmpl() [1/4]

template<typename ADDR >
CStreamSocketTmpl< ADDR >::CStreamSocketTmpl ( )
default

◆ CStreamSocketTmpl() [2/4]

template<typename ADDR >
CStreamSocketTmpl< ADDR >::CStreamSocketTmpl ( socket_t handle)
inlineexplicit

◆ CStreamSocketTmpl() [3/4]

template<typename ADDR >
CStreamSocketTmpl< ADDR >::CStreamSocketTmpl ( CStreamSocket && sock)
inlineexplicit

◆ CStreamSocketTmpl() [4/4]

template<typename ADDR >
CStreamSocketTmpl< ADDR >::CStreamSocketTmpl ( CStreamSocketTmpl< ADDR > && sock)
inlinenoexcept

Member Function Documentation

◆ bind() [1/2]

bool CSocket::bind ( const CSocketAddress & address)
virtualinherited

Asigna una dirección a un socket.

Parameters
addressDirección a la que el socket se va a asociar.
Returns
true si se ha podido asignar la dirección, false en caso contrario.

◆ bind() [2/2]

bool CSocket::bind ( const sockaddr * address,
socklen_t len ) const
inherited

◆ checkRet()

template<typename T >
T CSocket::checkRet ( T ret) const
inlineprotectedinherited

◆ checkRetBool()

template<typename T >
bool CSocket::checkRetBool ( T ret) const
inlineprotectedinherited

◆ checkSocket()

socket_t CSocket::checkSocket ( socket_t ret) const
inlineprotectedinherited

◆ checkSocketBool()

bool CSocket::checkSocketBool ( socket_t ret) const
inlineprotectedinherited

◆ clearLastError()

void CSocket::clearLastError ( int32_t value = 0) const
inherited

◆ clone()

CSocket CSocket::clone ( ) const
inherited

Crea un nuevo objeto CSocket con el mismo handle que el actual.

Note
No invalida el handle del objeto actual.
Returns
Nuevo objeto CSocket con el mismo handle que el actual.

◆ close() [1/2]

bool CSocket::close ( )
inherited

Cierra el socket.

Returns
true si se ha cerrado correctamente, false en caso contrario.

◆ close() [2/2]

bool CSocket::close ( socket_t h)
staticinherited

◆ closeOnError()

bool CSocket::closeOnError ( )
inlineprotectedinherited

◆ create() [1/3]

CSocket CSocket::create ( int32_t domain,
int32_t type,
int32_t protocol = 0 )
staticinherited

◆ create() [2/3]

CStreamSocket CStreamSocket::create ( int32_t domain,
int32_t protocol = 0 )
staticinherited

◆ create() [3/3]

template<typename ADDR >
CStreamSocketTmpl CStreamSocketTmpl< ADDR >::create ( int32_t protocol = 0)
inline

◆ createHandle()

static socket_t CStreamSocket::createHandle ( int32_t domain)
inlinestaticprotectedinherited

◆ getAddr()

template<typename ADDR >
addr_t CStreamSocketTmpl< ADDR >::getAddr ( ) const
inline

◆ getAddress()

CSocketAddressAny CSocket::getAddress ( ) const
virtualinherited

◆ getErrno()

int32_t CSocket::getErrno ( )
staticprotectedinherited

Función que devuelve el valor actual de errno.

Note
Esta función es estática pero protected, por lo que puede ser llamada desde las clases derivadas sin necesidad de crear un objeto de tipo CSocket.
Returns
Valor actual de errno.

◆ getFamily()

sa_family_t CSocket::getFamily ( ) const
virtualinherited

◆ getHandle()

socket_t CSocket::getHandle ( ) const
inherited

◆ getLastErrorString()

std::string CSocket::getLastErrorString ( ) const
inherited

◆ getOption() [1/2]

template<typename T >
bool CSocket::getOption ( const int32_t level,
const int32_t optName,
T * value ) const
inlineinherited

◆ getOption() [2/2]

bool CSocket::getOption ( int32_t level,
int32_t optName,
void * optVal,
socklen_t * optLength ) const
inherited

◆ getPeerAddr()

template<typename ADDR >
addr_t CStreamSocketTmpl< ADDR >::getPeerAddr ( ) const
inline

◆ getPeerAddress()

CSocketAddressAny CSocket::getPeerAddress ( ) const
virtualinherited

◆ isOpen()

bool CSocket::isOpen ( ) const
inherited

Comprueba que el handle del socket sea válido.

Returns
true si el handle es distinto de INVALID_SOCKET, false en caso contrario.

◆ operator bool()

CSocket::operator bool ( ) const
explicitinherited

Operador de conversión a bool.

Returns
true si el socket es válido y no hay ningún error, false en caso contrario.

◆ operator!()

bool CSocket::operator! ( ) const
inherited

Operador de negación.

Returns
true si el socket es válido o hay algún error, false en caso contrario.

◆ operator=()

template<typename ADDR >
CStreamSocketTmpl & CStreamSocketTmpl< ADDR >::operator= ( CStreamSocketTmpl< ADDR > && rhs)
inlinenoexcept

◆ pair() [1/2]

std::tuple< CSocket, CSocket > CSocket::pair ( int32_t domain,
int32_t type,
int32_t protocol = 0 )
staticinherited

◆ pair() [2/2]

template<typename ADDR >
static std::tuple< CStreamSocketTmpl, CStreamSocketTmpl > CStreamSocketTmpl< ADDR >::pair ( int32_t protocol = 0)
inlinestatic

◆ read() [1/2]

ssize_t CStreamSocket::read ( const std::vector< iovec > & ranges)
inherited

◆ read() [2/2]

ssize_t CStreamSocket::read ( void * buf,
size_t n )
virtualinherited

◆ read_n()

ssize_t CStreamSocket::read_n ( void * buf,
size_t n )
virtualinherited

◆ release()

socket_t CSocket::release ( )
inherited

Pone a -1 el handle interno y devuelve el valor anterior. Al no invalidar el file descriptor del socket, se puede usar para desasociar el socket del Sistema Operativo de un objeto CSocket concreto.

Returns
Valor del handle anterior.

◆ reset()

void CSocket::reset ( socket_t handle = INVALID_SOCKET)
inherited

Asigna un nuevo handle al socket e invalida el anterior.

Parameters
handleNuevo handle a asignar.

◆ setLastError()

void CSocket::setLastError ( int32_t err = INT32_MAX) const
inherited

◆ setNonBlocking()

bool CSocket::setNonBlocking ( bool on = true) const
inherited

◆ setOption() [1/2]

template<typename T >
bool CSocket::setOption ( const int32_t level,
const int32_t optName,
const T & value )
inlineinherited

◆ setOption() [2/2]

bool CSocket::setOption ( int32_t level,
int32_t optName,
const void * optVal,
socklen_t optLength ) const
inherited

◆ setReadTimeout() [1/2]

template<class Rep , class Period >
bool CStreamSocket::setReadTimeout ( const std::chrono::duration< Rep, Period > & to)
inlineinherited

◆ setReadTimeout() [2/2]

bool CStreamSocket::setReadTimeout ( const std::chrono::microseconds & to)
virtualinherited

◆ setWriteTimeout()

bool CStreamSocket::setWriteTimeout ( const std::chrono::microseconds & to)
virtualinherited

◆ write() [1/3]

virtual ssize_t CStreamSocket::write ( const std::string & s)
inlinevirtualinherited

◆ write() [2/3]

ssize_t CStreamSocket::write ( const std::vector< iovec > & ranges)
virtualinherited

◆ write() [3/3]

ssize_t CStreamSocket::write ( const void * buf,
size_t n )
virtualinherited

◆ write_n()

ssize_t CStreamSocket::write_n ( const void * buf,
size_t n )
virtualinherited

◆ write_timeout()

template<class Rep , class Period >
bool CStreamSocket::write_timeout ( const std::chrono::duration< Rep, Period > & to)
inlineinherited

Member Data Documentation

◆ ADDRESS_FAMILY

template<typename ADDR >
sa_family_t CStreamSocketTmpl< ADDR >::ADDRESS_FAMILY = ADDR::ADDRESS_FAMILY
staticconstexpr

◆ COMM_TYPE

int32_t CStreamSocket::COMM_TYPE = SOCK_STREAM
staticconstexprinherited

◆ m_handle

socket_t CSocket::m_handle
protectedinherited

◆ m_lastError

int32_t CSocket::m_lastError
mutableprivateinherited

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