sockpp
Modern C++ socket library wrapper
Public Member Functions | List of all members
sockpp::sock_address_any Class Reference

Generic socket address. More...

#include <sock_address.h>

Inheritance diagram for sockpp::sock_address_any:
sockpp::sock_address

Public Member Functions

 sock_address_any ()
 Constructs an empty address. More...
 
 sock_address_any (const sockaddr *addr, socklen_t n)
 Constructs an address. More...
 
 sock_address_any (const sockaddr_storage &addr, socklen_t n)
 Constructs an address. More...
 
 sock_address_any (const sock_address &addr)
 Copies another address to this one. More...
 
socklen_t size () const override
 Gets the size of the address. More...
 
const sockaddr * sockaddr_ptr () const override
 Gets a pointer to this object cast to a sockaddr. More...
 
sockaddr * sockaddr_ptr () override
 Gets a pointer to this object cast to a sockaddr. More...
 
- Public Member Functions inherited from sockpp::sock_address
virtual ~sock_address ()
 Virtual destructor.
 
virtual sa_family_t family () const
 Gets the network family of the address. More...
 

Detailed Description

Generic socket address.

This is a wrapper around sockaddr_storage which can hold any family address. This should have enough memory to contain any address struct for the system on which it is compiled.

Constructor & Destructor Documentation

◆ sock_address_any() [1/4]

sockpp::sock_address_any::sock_address_any ( )
inline

Constructs an empty address.

The address is initialized to all zeroes.

◆ sock_address_any() [2/4]

sockpp::sock_address_any::sock_address_any ( const sockaddr *  addr,
socklen_t  n 
)
inline

Constructs an address.

Parameters
addrPointer to a buffer holding the address.
nThe number of valid bytes in the address
Exceptions
std::length_errorif n is greater than the maximum size of an address.

◆ sock_address_any() [3/4]

sockpp::sock_address_any::sock_address_any ( const sockaddr_storage &  addr,
socklen_t  n 
)
inline

Constructs an address.

Parameters
addrThe buffer holding the address.
nThe number of valid bytes in the address
Exceptions
std::length_errorif n is greater than the maximum size of an address.

◆ sock_address_any() [4/4]

sockpp::sock_address_any::sock_address_any ( const sock_address addr)
inline

Copies another address to this one.

Parameters
addrThe other address to copy into this one.

Member Function Documentation

◆ size()

socklen_t sockpp::sock_address_any::size ( ) const
inlineoverridevirtual

Gets the size of the address.

Returns
The size of the address. This is the number of bytes that are a valid part of the address.

Implements sockpp::sock_address.

◆ sockaddr_ptr() [1/2]

const sockaddr* sockpp::sock_address_any::sockaddr_ptr ( ) const
inlineoverridevirtual

Gets a pointer to this object cast to a sockaddr.

Returns
A pointer to this object cast to a sockaddr.

Implements sockpp::sock_address.

◆ sockaddr_ptr() [2/2]

sockaddr* sockpp::sock_address_any::sockaddr_ptr ( )
inlineoverridevirtual

Gets a pointer to this object cast to a sockaddr.

Returns
A pointer to this object cast to a sockaddr.

Implements sockpp::sock_address.


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