Wizard
Software Engineering Project - Wizard
Loading...
Searching...
No Matches
sockpp::stream_socket_tmpl< ADDR > Class Template Reference

#include <stream_socket.h>

Inheritance diagram for sockpp::stream_socket_tmpl< ADDR >:
sockpp::stream_socket sockpp::socket

Public Types

using addr_t = ADDR
 

Public Member Functions

 stream_socket_tmpl ()
 
 stream_socket_tmpl (socket_t handle)
 
 stream_socket_tmpl (stream_socket &&sock)
 
 stream_socket_tmpl (stream_socket_tmpl &&sock)
 
stream_socket_tmploperator= (stream_socket_tmpl &&rhs)
 
stream_socket_tmpl create (int protocol=0)
 
addr_t address () const
 
addr_t peer_address () const
 
- 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 ()
 

Static Public Member Functions

static std::tuple< stream_socket_tmpl, stream_socket_tmplpair (int protocol=0)
 
- 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

static constexpr sa_family_t ADDRESS_FAMILY = ADDR::ADDRESS_FAMILY
 
- Static Public Attributes inherited from sockpp::stream_socket
static constexpr int COMM_TYPE = SOCK_STREAM
 

Additional Inherited Members

- 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

template<typename ADDR>
class sockpp::stream_socket_tmpl< ADDR >

Template for creating specific stream types (IPv4, IPv6, etc). This just overrides methods that take a generic address and replace them with the address type for a specific family. This doesn't add any runtime functionality, but has compile-time checks that address types aren't accidentally being mixed for an object.

Member Typedef Documentation

◆ addr_t

template<typename ADDR >
using sockpp::stream_socket_tmpl< ADDR >::addr_t = ADDR

The type of network address used with this socket.

Constructor & Destructor Documentation

◆ stream_socket_tmpl() [1/4]

template<typename ADDR >
sockpp::stream_socket_tmpl< ADDR >::stream_socket_tmpl ( )
inline

Creates an unconnected streaming socket.

◆ stream_socket_tmpl() [2/4]

template<typename ADDR >
sockpp::stream_socket_tmpl< ADDR >::stream_socket_tmpl ( socket_t handle)
inlineexplicit

Creates a streaming socket from an existing OS socket handle and claims ownership of the handle.

Parameters
handleA socket handle from the operating system.

◆ stream_socket_tmpl() [3/4]

template<typename ADDR >
sockpp::stream_socket_tmpl< ADDR >::stream_socket_tmpl ( stream_socket && sock)
inline

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

Parameters
sockAnother stream socket.

◆ stream_socket_tmpl() [4/4]

template<typename ADDR >
sockpp::stream_socket_tmpl< ADDR >::stream_socket_tmpl ( stream_socket_tmpl< ADDR > && sock)
inline

Creates a stream socket by copying the socket handle from the specified socket object and transfers ownership of the socket.

Member Function Documentation

◆ address()

template<typename ADDR >
addr_t sockpp::stream_socket_tmpl< ADDR >::address ( ) const
inline

Gets the local address to which the socket is bound.

Returns
The local address to which the socket is bound.
Exceptions
sys_erroron error

◆ create()

template<typename ADDR >
stream_socket_tmpl sockpp::stream_socket_tmpl< ADDR >::create ( int protocol = 0)
inline

Cretates a stream socket.

Parameters
protocolThe particular protocol to be used with the sockets
Returns
A stream socket

◆ operator=()

template<typename ADDR >
stream_socket_tmpl & sockpp::stream_socket_tmpl< ADDR >::operator= ( stream_socket_tmpl< ADDR > && rhs)
inline

Move assignment.

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

◆ pair()

template<typename ADDR >
static std::tuple< stream_socket_tmpl, stream_socket_tmpl > sockpp::stream_socket_tmpl< ADDR >::pair ( int protocol = 0)
inlinestatic

Creates a pair of connected stream sockets.

Whether this will work at all is highly system and domain dependent. Currently it is only known to work for Unix-domain sockets on *nix systems.

Parameters
protocolThe protocol to be used with the socket. (Normally 0)
Returns
A std::tuple of stream sockets. On error both sockets will be in an error state with the last error set.

◆ peer_address()

template<typename ADDR >
addr_t sockpp::stream_socket_tmpl< ADDR >::peer_address ( ) const
inline

Gets the address of the remote peer, if this socket is connected.

Returns
The address of the remote peer, if this socket is connected.
Exceptions
sys_erroron error

Member Data Documentation

◆ ADDRESS_FAMILY

template<typename ADDR >
sa_family_t sockpp::stream_socket_tmpl< ADDR >::ADDRESS_FAMILY = ADDR::ADDRESS_FAMILY
staticconstexpr

The address family for this type of address


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