Wizard
Software Engineering Project - Wizard
Loading...
Searching...
No Matches
sockpp::connector Class Reference

#include <connector.h>

Inheritance diagram for sockpp::connector:
sockpp::stream_socket sockpp::socket sockpp::connector_tmpl< STREAM_SOCK, ADDR >

Public Member Functions

 connector ()
 
 connector (const sock_address &addr)
 
 connector (connector &&conn)
 
connectoroperator= (connector &&rhs)
 
bool is_connected () const
 
bool connect (const sock_address &addr)
 
- Public Member Functions inherited from sockpp::stream_socket
 stream_socket ()
 
 stream_socket (socket_t handle)
 
 stream_socket (stream_socket &&sock)
 
stream_socketoperator= (stream_socket &&rhs)
 
stream_socket clone () const
 
virtual ssize_t read (void *buf, size_t n)
 
virtual ssize_t read_n (void *buf, size_t n)
 
ssize_t read (const std::vector< iovec > &ranges)
 
virtual bool read_timeout (const std::chrono::microseconds &to)
 
template<class Rep , class Period >
bool read_timeout (const std::chrono::duration< Rep, Period > &to)
 
virtual ssize_t write (const void *buf, size_t n)
 
virtual ssize_t write_n (const void *buf, size_t n)
 
virtual ssize_t write (const std::string &s)
 
virtual ssize_t write (const std::vector< iovec > &ranges)
 
virtual bool write_timeout (const std::chrono::microseconds &to)
 
template<class Rep , class Period >
bool write_timeout (const std::chrono::duration< Rep, Period > &to)
 
- Public Member Functions inherited from sockpp::socket
 socket ()
 
 socket (socket_t h)
 
 socket (socket &&sock) noexcept
 
virtual ~socket ()
 
bool is_open () const
 
bool operator! () const
 
 operator bool () const
 
socket_t handle () const
 
virtual sa_family_t family () const
 
socket clone () const
 
void clear (int val=0)
 
socket_t release ()
 
void reset (socket_t h=INVALID_SOCKET)
 
socketoperator= (socket &&sock) noexcept
 
bool bind (const sock_address &addr)
 
sock_address_any address () const
 
sock_address_any peer_address () const
 
bool get_option (int level, int optname, void *optval, socklen_t *optlen) const
 
template<typename T >
bool get_option (int level, int optname, T *val) const
 
bool set_option (int level, int optname, const void *optval, socklen_t optlen)
 
template<typename T >
bool set_option (int level, int optname, const T &val)
 
bool set_non_blocking (bool on=true)
 
int last_error () const
 
std::string last_error_str () const
 
bool shutdown (int how=SHUT_RDWR)
 
bool close ()
 

Additional Inherited Members

- Static Public Member Functions inherited from sockpp::stream_socket
static stream_socket create (int domain, int protocol=0)
 
- Static Public Member Functions inherited from sockpp::socket
static void initialize ()
 
static void destroy ()
 
static socket create (int domain, int type, int protocol=0)
 
static std::tuple< socket, socketpair (int domain, int type, int protocol=0)
 
static std::string error_str (int errNum)
 
- Static Public Attributes inherited from sockpp::stream_socket
static constexpr int COMM_TYPE = SOCK_STREAM
 
- Protected Member Functions inherited from sockpp::socket
bool close_on_err ()
 
void set_last_error ()
 
template<typename T >
check_ret (T ret) const
 
template<typename T >
bool check_ret_bool (T ret) const
 
socket_t check_socket (socket_t ret) const
 
bool check_socket_bool (socket_t ret) const
 
- Static Protected Member Functions inherited from sockpp::stream_socket
static socket_t create_handle (int domain)
 
- Static Protected Member Functions inherited from sockpp::socket
static int get_last_error ()
 

Detailed Description

Class to create a client stream connection. This is a base class for creating active, streaming sockets that initiate connections to a server. It can be used to derive classes that implement TCP on IPv4 or IPv6.

Constructor & Destructor Documentation

◆ connector() [1/3]

sockpp::connector::connector ( )
inline

Creates an unconnected connector.

◆ connector() [2/3]

sockpp::connector::connector ( const sock_address & addr)
inline

Creates the connector and attempts to connect to the specified address.

Parameters
addrThe remote server address.

◆ connector() [3/3]

sockpp::connector::connector ( connector && conn)
inline

Move constructor. Creates a connector by moving the other connector to this one.

Parameters
connAnother connector.

Member Function Documentation

◆ connect()

bool sockpp::connector::connect ( const sock_address & addr)

Attempts to connect to the specified server. If the socket is currently connected, this will close the current connection and open the new one.

Parameters
addrThe remote server address.
Returns
true on _success, false on error

◆ is_connected()

bool sockpp::connector::is_connected ( ) const
inline

Determines if the socket connected to a remote host. Note that this is not a reliable determination if the socket is currently connected, but rather that an initial connection was established.

Returns
true If the socket connected to a remote host, false if not.

◆ operator=()

connector & sockpp::connector::operator= ( connector && rhs)
inline

Move assignment.

Parameters
rhsThe other connector to move into this one.
Returns
A reference to this object.

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