Nix (Dev) 3.5.10
dev - 3.5.10 - 1af9301
Loading...
Searching...
No Matches
CConnectorSocketTmpl< STREAM_SOCK, ADDR > Class Template Referencefinal

#include <CConnectorSocket.hpp>

Inheritance diagram for CConnectorSocketTmpl< STREAM_SOCK, ADDR >:
[legend]
Collaboration diagram for CConnectorSocketTmpl< STREAM_SOCK, ADDR >:
[legend]

Public Types

using stream_sock_t = STREAM_SOCK
 
using addr_t = ADDR
 

Public Member Functions

 CConnectorSocketTmpl ()=default
 
 CConnectorSocketTmpl (const CConnectorSocketTmpl &)=delete
 
CConnectorSocketTmploperator= (const CConnectorSocketTmpl &)=delete
 
 CConnectorSocketTmpl (const addr_t &address)
 
CConnectorSocketTmploperator= (CConnectorSocketTmpl &&rhs) noexcept
 
bool connect (const addr_t &address)
 
addr_t getOwnAddress () const
 
addr_t getPeerAddr () const
 
bool connect (const CSocketAddress &address, int32_t milliseconds=defaultConnectionTimeoutMs)
 
bool isConnected () 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 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 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 Member Functions

bool prv_setTimeOut (socket_t fd, int32_t milliseconds)
 

Private Attributes

int32_t m_lastError
 

Static Private Attributes

static constexpr int32_t defaultConnectionTimeoutMs = 1000
 

Member Typedef Documentation

◆ addr_t

template<typename STREAM_SOCK , typename ADDR = typename STREAM_SOCK::addr_t>
using CConnectorSocketTmpl< STREAM_SOCK, ADDR >::addr_t = ADDR

◆ stream_sock_t

template<typename STREAM_SOCK , typename ADDR = typename STREAM_SOCK::addr_t>
using CConnectorSocketTmpl< STREAM_SOCK, ADDR >::stream_sock_t = STREAM_SOCK

Constructor & Destructor Documentation

◆ CConnectorSocketTmpl() [1/3]

template<typename STREAM_SOCK , typename ADDR = typename STREAM_SOCK::addr_t>
CConnectorSocketTmpl< STREAM_SOCK, ADDR >::CConnectorSocketTmpl ( )
default

◆ CConnectorSocketTmpl() [2/3]

template<typename STREAM_SOCK , typename ADDR = typename STREAM_SOCK::addr_t>
CConnectorSocketTmpl< STREAM_SOCK, ADDR >::CConnectorSocketTmpl ( const CConnectorSocketTmpl< STREAM_SOCK, ADDR > & )
delete

◆ CConnectorSocketTmpl() [3/3]

template<typename STREAM_SOCK , typename ADDR = typename STREAM_SOCK::addr_t>
CConnectorSocketTmpl< STREAM_SOCK, ADDR >::CConnectorSocketTmpl ( const addr_t & address)
inlineexplicit

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

◆ connect() [1/2]

bool CConnectorSocket::connect ( const CSocketAddress & address,
int32_t milliseconds = defaultConnectionTimeoutMs )
inherited

◆ connect() [2/2]

template<typename STREAM_SOCK , typename ADDR = typename STREAM_SOCK::addr_t>
bool CConnectorSocketTmpl< STREAM_SOCK, ADDR >::connect ( const addr_t & address)
inline

◆ create() [1/2]

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

◆ create() [2/2]

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

◆ createHandle()

static socket_t CStreamSocket::createHandle ( int32_t domain)
inlinestaticprotectedinherited

◆ 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

◆ getOwnAddress()

template<typename STREAM_SOCK , typename ADDR = typename STREAM_SOCK::addr_t>
addr_t CConnectorSocketTmpl< STREAM_SOCK, ADDR >::getOwnAddress ( ) const
inline

◆ getPeerAddr()

template<typename STREAM_SOCK , typename ADDR = typename STREAM_SOCK::addr_t>
addr_t CConnectorSocketTmpl< STREAM_SOCK, ADDR >::getPeerAddr ( ) const
inline

◆ getPeerAddress()

CSocketAddressAny CSocket::getPeerAddress ( ) const
virtualinherited

◆ isConnected()

bool CConnectorSocket::isConnected ( ) const
inlineinherited

◆ 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=() [1/2]

template<typename STREAM_SOCK , typename ADDR = typename STREAM_SOCK::addr_t>
CConnectorSocketTmpl & CConnectorSocketTmpl< STREAM_SOCK, ADDR >::operator= ( CConnectorSocketTmpl< STREAM_SOCK, ADDR > && rhs)
inlinenoexcept

◆ operator=() [2/2]

template<typename STREAM_SOCK , typename ADDR = typename STREAM_SOCK::addr_t>
CConnectorSocketTmpl & CConnectorSocketTmpl< STREAM_SOCK, ADDR >::operator= ( const CConnectorSocketTmpl< STREAM_SOCK, ADDR > & )
delete

◆ pair()

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

◆ prv_setTimeOut()

bool CConnectorSocket::prv_setTimeOut ( socket_t fd,
int32_t milliseconds )
privateinherited

◆ 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

◆ COMM_TYPE

int32_t CStreamSocket::COMM_TYPE = SOCK_STREAM
staticconstexprinherited

◆ defaultConnectionTimeoutMs

int32_t CConnectorSocket::defaultConnectionTimeoutMs = 1000
staticconstexprprivateinherited

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