#include <senf/Socket/Protocols/BSDSocketAddress.hh>
BSDSocketAddress is the base class of all BSD sockaddr
based addressing classes. The sockaddr
addressing interface is split into several parts
sockaddr
interfaceAF_INET
), INet6SocketAddress (AF_INET6
), UNSocketAddress (AF_UNIX
) and LLSocketAddress (AF_PACKET
)A BSDSocketAddress or GenericBSDSocketAddress can be cast (like a downcast) to (the correct) type specific cast using sockaddr_cast:
void foo(senf::BSDSOcketAddress const & addr) { if (addr.family() == senf::INet4SocketAddress::addressFamily) { senf::INet4SocketAddress i4addr ( senf::sockaddr_cast<senf::INet4SocketAddress>(addr) ); ... } }
All these classes provide a generic sockaddr
API to interface with legacy sockaddr
based code (e.g. the BSD socket API). In this base-class, this interface is read-only, the derived classes however provide a read-write interface.
Definition at line 76 of file BSDSocketAddress.hh.
Public Member Functions |
|
bool | operator== (BSDSocketAddress const &other) const |
Compare two arbitrary addresses. |
|
bool | operator< (BSDSocketAddress const &other) const |
Compare two arbitrary addresses. |
|
bool | boolean_test () const |
Return true , if address is not empty. |
|
short | family () const |
Return the address family. |
|
Related Functions |
|
(Note that these are not member functions.) |
|
template<class Target > | |
Target & | sockaddr_cast (BSDSocketAddress &source) |
Safe socket address down-cast. |
|
template<class Target > | |
Target const & | sockaddr_cast (BSDSocketAddress const &source) |
Safe socket address down-cast (const). |
|
std::ostream & | operator<< (std::ostream &os, BSDSocketAddress const &addr) |
Output generic socket address. |
|
Generic sockaddr interface |
|
struct sockaddr const * | sockaddr_p () const |
socklen_t | socklen () const |
socklen_t const * | socklen_p () const |
Protected Member Functions |
|
BSDSocketAddress (socklen_t len, short family) | |
BSDSocketAddress (BSDSocketAddress const &other) | |
BSDSocketAddress & | operator= (BSDSocketAddress const &other) |
struct sockaddr * | sockaddr_p () |
socklen_t * | socklen_p () |
void | socklen (socklen_t len) |
senf::BSDSocketAddress:: | ||||
BSDSocketAddress | ( | socklen_t | len, | |
short | family | ) | ||
Definition at line 94 of file BSDSocketAddress.cci.
senf::BSDSocketAddress:: | ||||
BSDSocketAddress | ( | BSDSocketAddress const & | other | ) |
Definition at line 113 of file BSDSocketAddress.cci.
bool senf::BSDSocketAddress:: | ||||
boolean_test | () | |||
Return true
, if address is not empty.
An address is considered empty if
Definition at line 82 of file BSDSocketAddress.cci.
short senf::BSDSocketAddress:: | ||||
family | () | |||
Return the address family.
This value is found in the addressFamily
member of each typed derived class (e.g. INet4Address::addressFamily)
Definition at line 45 of file BSDSocketAddress.cci.
bool senf::BSDSocketAddress:: | ||||
operator< | ( | BSDSocketAddress const & | other | ) |
Compare two arbitrary addresses.
Ordering is based on the in-memory representation. It is primarily useful to use addresses as keys in a map or set.
Definition at line 74 of file BSDSocketAddress.cci.
senf::BSDSocketAddress & senf::BSDSocketAddress:: | ||||
operator= | ( | BSDSocketAddress const & | other | ) |
Reimplemented in senf::GenericBSDSocketAddress.
Definition at line 120 of file BSDSocketAddress.cci.
bool senf::BSDSocketAddress:: | ||||
operator== | ( | BSDSocketAddress const & | other | ) |
Compare two arbitrary addresses.
For addresses to be considered equal, they must have the same family, length and the data must be identical.
Definition at line 68 of file BSDSocketAddress.cci.
struct sockaddr * senf::BSDSocketAddress:: | ||||
sockaddr_p | () | |||
Reimplemented in senf::GenericBSDSocketAddress.
Definition at line 128 of file BSDSocketAddress.cci.
struct sockaddr const * senf::BSDSocketAddress:: | ||||
sockaddr_p | () | |||
Reimplemented in senf::GenericBSDSocketAddress.
Definition at line 39 of file BSDSocketAddress.cci.
void senf::BSDSocketAddress:: | ||||
socklen | ( | socklen_t | len | ) |
Definition at line 63 of file BSDSocketAddress.cci.
socklen_t senf::BSDSocketAddress:: | ||||
socklen | () | |||
Definition at line 51 of file BSDSocketAddress.cci.
socklen_t * senf::BSDSocketAddress:: | ||||
socklen_p | () | |||
Definition at line 133 of file BSDSocketAddress.cci.
socklen_t const * senf::BSDSocketAddress:: | ||||
socklen_p | () | |||
Definition at line 57 of file BSDSocketAddress.cci.
std::ostream & | ||||
operator<< | ( | std::ostream & | os, | |
BSDSocketAddress const & | addr | ) | ||
Output generic socket address.
This stream operator will output a generic BSDSocketAddress in a family depending format.
Target const & | ||||
sockaddr_cast | ( | BSDSocketAddress const & | source | ) |
Safe socket address down-cast (const).
Target & | ||||
sockaddr_cast | ( | BSDSocketAddress & | source | ) |
Safe socket address down-cast.
sockaddr_cast allows to safely cast a socket address to it's derived type. Only the family specific derived addressing classes are permissible for Target.
This cast is especially useful to cast a GenericBSDSocketAddress to it's concrete type.
char senf::BSDSocketAddress::_b[boost::alignment_of< struct sockaddr_storage >:: | ||||
value] | ||||
Definition at line 130 of file BSDSocketAddress.hh.
boost::type_with_alignment<boost::alignment_of<struct sockaddr_storage>::value> senf::BSDSocketAddress:: | ||||
a_ | ||||
Definition at line 129 of file BSDSocketAddress.hh.
socklen_t senf::BSDSocketAddress:: | ||||
len_ | ||||
Definition at line 128 of file BSDSocketAddress.hh.