Simple++
Powerfull and lightning fast C++ Library
Public Member Functions | Protected Member Functions | List of all members
Network::Address Class Reference

Extended and safer version of AddrInfo. More...

#include <Address.h>

Inheritance diagram for Network::Address:
Network::AddrInfo Network::Connection

Public Member Functions

 Address (SockType sockType=SockType::TCP, IpFamily ipFamily=IpFamily::Undefined)
 Constructor from a SockType and an IpFamily. More...
 
 Address (const String &address, const String &service, SockType sockType=SockType::TCP, IpFamily ipFamily=IpFamily::Undefined)
 Constructor from a IP, Service, SockType and IpFamily. More...
 
 Address (const String &address, const String &service, const AddrInfo &hints)
 Constructor from a IP, Service, SockType and IpFamily. More...
 
 Address (const AddrInfo &addrInfo)
 copy constructor to up cast More...
 
 Address (const Address &address)
 copy constructor More...
 
 Address (Address &&address)
 move constructor More...
 
 Address (const struct addrinfo &addrInfo)
 copy constructor from an old-school struct addrinfo More...
 
 ~Address ()
 destructor More...
 
Addressoperator= (const AddrInfo &addrInfo)
 copy operator from an AddrInfo More...
 
Addressoperator= (const Address &address)
 copy operator More...
 
Addressoperator= (Address &&address)
 move operator More...
 
unsigned short getPort ()
 get the port as unsigned short (this function use buffered values) More...
 
const StringgetIp ()
 get the IP as a String (this function use buffered values) More...
 

Protected Member Functions

 Address (ctor)
 
void _update ()
 
- Protected Member Functions inherited from Network::AddrInfo
 AddrInfo (ctor)
 
 AddrInfo (SockType sockType=SockType::TCP, IpFamily ipFamily=IpFamily::Undefined)
 Create an AddrInfo from a SockType and an IpFamily. More...
 
 AddrInfo (const String &address, const String &service, SockType sockType=SockType::TCP, IpFamily ipFamily=IpFamily::Undefined)
 Constructor from a IP, Service, SockType and IpFamily. More...
 
 AddrInfo (const String &address, const String &service, const AddrInfo &hints)
 Constructor from a IP, Service, SockType and IpFamily. More...
 
 AddrInfo (const AddrInfo &addrInfo)
 Copy constructor. More...
 
 AddrInfo (AddrInfo &&addrInfo)
 move constructor More...
 
 AddrInfo (const AddrInfo &addrInfo, SockType sockType, IpFamily ipFamily, unsigned short port)
 Copy constructor with an another SockType, IpFamily and port. More...
 
 AddrInfo (const struct addrinfo &addrInfo)
 Copy constructor from an old-school struct addrinfo. More...
 
 ~AddrInfo ()
 destructor More...
 
const struct addrinfo * getAddrInfoStruct () const
 get the old-school struct addrinfo inside this type. More...
 
void setSockAddr (const struct sockaddr *sockAddr, size_t sockAddrLen)
 set the struct sockaddr contained inside this object More...
 
AddrInfooperator= (const AddrInfo &addrInfo)
 set the inside address More...
 
AddrInfooperator= (const struct addrinfo &addrInfo)
 copy operator from a old-school struct addrinfo More...
 
AddrInfooperator= (AddrInfo &&addrInfo)
 move operator More...
 
const struct sockaddr * getSockAddr () const
 get the struct sockaddr of this object More...
 
void newSockAddr (size_t newSize)
 set the struct sockaddr to a new one filled with 0 More...
 
void setPort (const struct sockaddr *sockAddr)
 set the sockaddr port from an another sockaddr More...
 
size_t getSockAddrLen () const
 get the length in bytes of the struct sockaddr More...
 
IpFamily getIpFamily (const std::string &ip)
 get the IP family More...
 
unsigned short getPort () const
 get the port More...
 
IpFamily getIpFamily () const
 get the IP family More...
 
const StringgetIpFamilyS () const
 get the IP�family as a String More...
 
int getProtocol () const
 get the Protocol More...
 
SockType getSockType () const
 get the SockType (UDP or TCP) More...
 
const StringgetSockTypeS () const
 get the SockType as a String More...
 
void setFlags (int flags)
 set flags More...
 
int getFlags () const
 get Flags More...
 
void addFlag (Flags flags)
 add a Flag to this object Flag to add More...
 
void setCanonName (const String &name)
 set the CanonName of this object More...
 
String getNameInfo () const
 getnameinfo() on the struct sockaddr inside this object More...
 
void setPort (unsigned short port)
 set the sockaddr port More...
 
void setIpFamily (IpFamily ipFamily)
 set the IP family of this addrinfo (this won't change the struct sockaddr and may corrupt this object) More...
 
void setProtocol (int protocol)
 set the Protocol of this (this won't change the struct sockaddr and may corrupt this object) More...
 
void setSockType (SockType sockType)
 set the SockType (TCP or UDP) (this won't change the struct sockaddr and may corrupt this object) More...
 

Additional Inherited Members

- Protected Types inherited from Network::AddrInfo
enum  ctor { null }
 
- Static Protected Member Functions inherited from Network::AddrInfo
static String getNameInfo (const struct sockaddr &sockAddr, size_t sockAddrLen)
 alias of getnameinfo() and cast the result to a String More...
 
static String getNameInfo (const struct addrinfo &addrInfo)
 alias of getnameinfo() of the struct sockaddr inside the struct addrinfo More...
 
static unsigned short getPort (const struct sockaddr &sockAddr)
 get the port a struct sockaddr as an unsigned short More...
 

Detailed Description

Extended and safer version of AddrInfo.

Constructor & Destructor Documentation

Network::Address::Address ( SockType  sockType = SockType::TCP,
IpFamily  ipFamily = IpFamily::Undefined 
)

Constructor from a SockType and an IpFamily.

Parameters
sockTypeSockType of this Address (TCP or UDP)
ipFamilyIpFamily to set (IPv4, IPv6 or Undefined)
Network::Address::Address ( const String address,
const String service,
SockType  sockType = SockType::TCP,
IpFamily  ipFamily = IpFamily::Undefined 
)

Constructor from a IP, Service, SockType and IpFamily.

Parameters
addressto connect to (IP or domain name)
serviceService to be used.
sockTypeSockType
ipFamilyIpFamily
Network::Address::Address ( const String address,
const String service,
const AddrInfo hints 
)

Constructor from a IP, Service, SockType and IpFamily.

Parameters
addressto connect to (IP or domain name)
serviceService to be used.
hintsHints to be used (sockType, ipFamily, flags, protocol)
Network::Address::Address ( const AddrInfo addrInfo)

copy constructor to up cast

Parameters
addrInfo
Network::Address::Address ( const Address address)

copy constructor

Parameters
addressobject to copy
Network::Address::Address ( Address &&  address)

move constructor

Parameters
addressObject to move from.
Network::Address::Address ( const struct addrinfo &  addrInfo)

copy constructor from an old-school struct addrinfo

Parameters
addrInfostruct addrinfo to copy
Network::Address::~Address ( )

destructor

Network::Address::Address ( ctor  )
protected

Member Function Documentation

void Network::Address::_update ( )
protected
const String & Network::Address::getIp ( )

get the IP as a String (this function use buffered values)

Returns
IP as String
unsigned short Network::Address::getPort ( )

get the port as unsigned short (this function use buffered values)

Returns
Port as unsigned short
Address & Network::Address::operator= ( const AddrInfo addrInfo)

copy operator from an AddrInfo

Parameters
addrInfoAddrInfo Object to copy
Address & Network::Address::operator= ( const Address address)

copy operator

Parameters
addressObject to copy
Address & Network::Address::operator= ( Address &&  address)

move operator

Parameters
addressobject to move from
Returns
reference to this

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