IPv4 socket address. More...

#include <senf/Socket/Protocols/INet/INetAddressing.hh>

Inheritance diagram for senf::INet4SocketAddress:

Public Member Functions

INet4Address address () const
 Return address. More...
 
unsigned port () const
 Return port number. More...
 
void address (INet4Address const &addr)
 Set address. More...
 
void port (unsigned p)
 Set port number. More...
 
- Public Member Functions inherited from senf::BSDSocketAddress
bool operator== (BSDSocketAddress const &other) const
 Compare two arbitrary addresses. More...
 
bool operator< (BSDSocketAddress const &other) const
 Compare two arbitrary addresses. More...
 
bool boolean_test () const
 Return true, if address is not empty. More...
 
short family () const
 Return the address family. More...
 
struct sockaddr const * sockaddr_p () const
 
socklen_t socklen () const
 
socklen_t const * socklen_p () const
 
- Public Member Functions inherited from senf::comparable_safe_bool< BSDSocketAddress >
 operator bool_type () const
 
bool operator! () const
 

Static Public Attributes

static short const addressFamily = AF_INET
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &os, INet4SocketAddress const &addr)
 Write address and port to os. More...
 

Structors and default members

 INet4SocketAddress ()
 
 INet4SocketAddress (std::string const &addr)
 Set address and port. More...
 
 INet4SocketAddress (INet4Address const &addr, unsigned port)
 Set address and port explicitly. More...
 
 INet4SocketAddress (unsigned port)
 Set port, address is set to 0.0.0.0. More...
 
 INet4SocketAddress (const INet4SocketAddress &other)
 
INet4SocketAddressoperator= (const INet4SocketAddress &other)
 

Additional Inherited Members

- Protected Types inherited from senf::safe_bool_base
typedef void(safe_bool_base::* bool_type) () const
 
- Protected Member Functions inherited from senf::BSDSocketAddress
 BSDSocketAddress (socklen_t len, short family)
 
 BSDSocketAddress (BSDSocketAddress const &other)
 
BSDSocketAddressoperator= (BSDSocketAddress const &other)
 
struct sockaddr * sockaddr_p ()
 
socklen_t * socklen_p ()
 
void socklen (socklen_t len)
 
- Protected Member Functions inherited from senf::comparable_safe_bool< BSDSocketAddress >
 ~comparable_safe_bool ()
 
- Protected Member Functions inherited from senf::safe_bool_base
void this_type_does_not_support_comparisons () const
 
 safe_bool_base ()
 
 safe_bool_base (const safe_bool_base &)
 
safe_bool_baseoperator= (const safe_bool_base &)
 
 ~safe_bool_base ()
 

Detailed Description

IPv4 socket address.

INet4Address wraps the standard sockaddr_in datatype. It provides simple accessor methods to access the host and port. It does not integrate gethostbyname or DNS lookup.

Implementation note:
This implementation is based on sockaddr_in, which is needed since it needs to provide a non-const struct sockaddr * for legacy compatibility.

Definition at line 44 of file INetAddressing.hh.

Constructor & Destructor Documentation

◆ INet4SocketAddress() [1/5]

senf::INet4SocketAddress::INet4SocketAddress ( )

◆ INet4SocketAddress() [2/5]

senf::INet4SocketAddress::INet4SocketAddress ( std::string const &  addr)
explicit

Set address and port.

This constructor expects a string of the form 'host:port'. The constructor will use this value to initialize the host and port members. Since it uses the INet4Address::from_string constructor, this call may block while waiting for the resolver.

Exceptions
AddressSyntaxExceptionif the address syntax is invalid
UnknownHostnameExceptionif the address cannot be resolved.

Definition at line 38 of file INetAddressing.cc.

◆ INet4SocketAddress() [3/5]

senf::INet4SocketAddress::INet4SocketAddress ( INet4Address const &  addr,
unsigned  port 
)

Set address and port explicitly.

Parameters
[in]addrIP address
[in]portport number

Definition at line 52 of file INetAddressing.cc.

◆ INet4SocketAddress() [4/5]

senf::INet4SocketAddress::INet4SocketAddress ( unsigned  port)
explicit

Set port, address is set to 0.0.0.0.

Parameters
[in]portport number

Definition at line 59 of file INetAddressing.cc.

◆ INet4SocketAddress() [5/5]

senf::INet4SocketAddress::INet4SocketAddress ( const INet4SocketAddress other)

Member Function Documentation

◆ address() [1/2]

INet4Address senf::INet4SocketAddress::address ( ) const

Return address.

◆ address() [2/2]

void senf::INet4SocketAddress::address ( INet4Address const &  addr)

Set address.

◆ operator=()

INet4SocketAddress& senf::INet4SocketAddress::operator= ( const INet4SocketAddress other)

◆ port() [1/2]

unsigned senf::INet4SocketAddress::port ( ) const

Return port number.

◆ port() [2/2]

void senf::INet4SocketAddress::port ( unsigned  p)

Set port number.

Friends And Related Function Documentation

◆ operator<<()

std::ostream & operator<< ( std::ostream &  os,
INet4SocketAddress const &  addr 
)
related

Write address and port to os.

Member Data Documentation

◆ addressFamily

short const senf::INet4SocketAddress::addressFamily = AF_INET
static

Definition at line 48 of file INetAddressing.hh.


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