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

Representing a struct addrinfo, all the info of an address without the "list" side ai_next is not used. This class can be down casted freely to struct addrinfo. Warning when using this class, you may prefer using Address Class which is more safer. More...

#include <AddrInfo.h>

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

Public Member Functions

 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...
 

Static Public Member Functions

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...
 

Protected Types

enum  ctor { null }
 

Protected Member Functions

 AddrInfo (ctor)
 

Detailed Description

Representing a struct addrinfo, all the info of an address without the "list" side ai_next is not used. This class can be down casted freely to struct addrinfo. Warning when using this class, you may prefer using Address Class which is more safer.

Member Enumeration Documentation

enum Network::AddrInfo::ctor
protected
Enumerator
null 

Constructor & Destructor Documentation

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

Create an AddrInfo from a SockType and an IpFamily.

Parameters
sockTypeType of the socket used for this connection (TCP or UDP)
ipFamilyThe IP family used for this connection (IPv4, IPv6 or both)
Network::AddrInfo::AddrInfo ( 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::AddrInfo::AddrInfo ( 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::AddrInfo::AddrInfo ( const AddrInfo addrInfo)

Copy constructor.

Parameters
addrInfoobject to copy
Network::AddrInfo::AddrInfo ( AddrInfo &&  addrInfo)

move constructor

Parameters
addrInfoobject to be moved from
Network::AddrInfo::AddrInfo ( const AddrInfo addrInfo,
SockType  sockType,
IpFamily  ipFamily,
unsigned short  port 
)

Copy constructor with an another SockType, IpFamily and port.

Parameters
addrInfoobject to copy
Network::AddrInfo::AddrInfo ( const struct addrinfo &  addrInfo)

Copy constructor from an old-school struct addrinfo.

Parameters
addrInfoold-school struct addrinfo
Network::AddrInfo::~AddrInfo ( )

destructor

Network::AddrInfo::AddrInfo ( ctor  )
protected

Member Function Documentation

void Network::AddrInfo::addFlag ( Flags  flags)

add a Flag to this object Flag to add

const struct addrinfo * Network::AddrInfo::getAddrInfoStruct ( ) const

get the old-school struct addrinfo inside this type.

Returns
the old-school struct addrinfo structure.
int Network::AddrInfo::getFlags ( ) const

get Flags

Returns
Flags
IpFamily Network::AddrInfo::getIpFamily ( const std::string &  ip)

get the IP family

Returns
IP family
IpFamily Network::AddrInfo::getIpFamily ( ) const

get the IP family

Returns
the IP family
const String & Network::AddrInfo::getIpFamilyS ( ) const

get the IP�family as a String

Returns
IP family as a string
String Network::AddrInfo::getNameInfo ( const struct sockaddr &  sockAddr,
size_t  sockAddrLen 
)
static

alias of getnameinfo() and cast the result to a String

Parameters
sockAddrSockAddr from which to get the name
sockAddrLenlength in bytes of the struct sockaddr
Returns
String representing the struct sockaddr
String Network::AddrInfo::getNameInfo ( const struct addrinfo &  addrInfo)
static

alias of getnameinfo() of the struct sockaddr inside the struct addrinfo

Parameters
addrInfogetnameinfo() will be executed to the struct sockaddr inside
Returns
String
String Network::AddrInfo::getNameInfo ( ) const

getnameinfo() on the struct sockaddr inside this object

Returns
String representing the struct sockaddr
unsigned short Network::AddrInfo::getPort ( ) const

get the port

Returns
port if the struct sockaddr * is not NULL, 0 else
unsigned short Network::AddrInfo::getPort ( const struct sockaddr &  sockAddr)
static

get the port a struct sockaddr as an unsigned short

Returns
Port as unsigned short
int Network::AddrInfo::getProtocol ( ) const

get the Protocol

Returns
Protocol
const struct sockaddr * Network::AddrInfo::getSockAddr ( ) const

get the struct sockaddr of this object

size_t Network::AddrInfo::getSockAddrLen ( ) const

get the length in bytes of the struct sockaddr

Returns
length in bytes of the sockaddr
SockType Network::AddrInfo::getSockType ( ) const

get the SockType (UDP or TCP)

Returns
SockType
const String & Network::AddrInfo::getSockTypeS ( ) const

get the SockType as a String

Returns
SockType as a String
void Network::AddrInfo::newSockAddr ( size_t  newSize)

set the struct sockaddr to a new one filled with 0

Parameters
newSizesize in bytes of the new sockaddr
AddrInfo & Network::AddrInfo::operator= ( const AddrInfo addrInfo)

set the inside address

Parameters
ipIP to look for
serviceService to look for ("http", 80, ...)
ipFamilyIPv4, IPv6 or Undefined to look for the two copy operator
addrInfoother object to copy
Returns
this object as a reference
AddrInfo & Network::AddrInfo::operator= ( const struct addrinfo &  addrInfo)

copy operator from a old-school struct addrinfo

Parameters
addrInfostruct addrinfo to copy
Returns
this object as a reference
AddrInfo & Network::AddrInfo::operator= ( AddrInfo &&  addrInfo)

move operator

Parameters
addrInfofrom which to move
Returns
reference of this
void Network::AddrInfo::setCanonName ( const String name)

set the CanonName of this object

Parameters
nameCanonName to set
void Network::AddrInfo::setFlags ( int  flags)

set flags

Parameters
flagsFlags to set
void Network::AddrInfo::setIpFamily ( IpFamily  ipFamily)

set the IP family of this addrinfo (this won't change the struct sockaddr and may corrupt this object)

Parameters
ipFamilyIP Family to set
void Network::AddrInfo::setPort ( const struct sockaddr *  sockAddr)

set the sockaddr port from an another sockaddr

Parameters
sockaddrstruct sockaddr where to copy the port
void Network::AddrInfo::setPort ( unsigned short  port)

set the sockaddr port

Parameters
portPort as an unsigned short
void Network::AddrInfo::setProtocol ( int  protocol)

set the Protocol of this (this won't change the struct sockaddr and may corrupt this object)

Parameters
protocolProtocol
void Network::AddrInfo::setSockAddr ( const struct sockaddr *  sockAddr,
size_t  sockAddrLen 
)

set the struct sockaddr contained inside this object

Parameters
sockAddrstruct sockaddr to set (can be NULL)
sockAddrLensize of the sockAddr in bytes
void Network::AddrInfo::setSockType ( SockType  sockType)

set the SockType (TCP or UDP) (this won't change the struct sockaddr and may corrupt this object)

Parameters
sockType

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