# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

NLNET::CInetAddress Class Reference

Internet address (IP + port). More...

#include <inet_address.h>

List of all members.

Public Methods

 CInetAddress ()
 Default Constructor. The address is set to INADDR_ANY. More...

 CInetAddress ( const std::string& hostName, uint16 port )
 Alternate constructor (calls setByName()). More...

 CInetAddress ( const std::string& hostNameAndPort )
 Alternate constructor (calls setByName()) example: CInetAddress("www.nevrax.com:80"). More...

 CInetAddress ( const CInetAddress& other )
 Copy constructor. More...

CInetAddress& operator= ( const CInetAddress& other )
 Assignment operator. More...

 ~CInetAddress ()
 Destructor. More...

CInetAddress& setByName ( const std::string& hostname )
 Resolves a name. More...

void setPort ( uint16 port )
 Sets port. More...

void setSockAddr ( const sockaddr_in* saddr )
 Sets internal socket address directly (contents is copied). More...

bool isValid () const
 Returns if object (address and port) is valid. More...

const sockaddr_in* sockAddr () const
 Returns internal socket address (read only). More...

uint32 internalIPAddress () const
 Returns internal IP address. More...

std::string ipAddress () const
 Returns readable IP address. More...

const std::string& hostName () const
 Returns hostname. More...

uint16 port () const
 Returns port. More...

std::string asString () const
 Returns hostname and port as a string. More...

std::string asIPString () const
 Returns IP address and port as a string. More...

void serial ( NLMISC::IStream& s )
 Serialize. More...


Static Public Methods

CInetAddress localHost ()
 Creates a CInetAddress object with local host address, port=0. More...


Static Public Attributes

bool RetrieveNames = true
 If true, setSockAddr() always tries to retrieve the host name from the address. More...


Private Methods

void init ()

Private Attributes

std::string _HostName
sockaddr_in* _SockAddr
bool _Valid

Friends

bool operator== ( const CInetAddress& a1, const CInetAddress& a2 )
 Comparison == operator. More...

bool operator< ( const CInetAddress& a1, const CInetAddress& a2 )
 Comparison < operator. More...


Detailed Description

Internet address (IP + port).

The structure sockaddr_in is internally in network byte order

Todo:
cado Test big/little endian transfers to check if byte ordering is ok.
Author(s):
Olivier Cado , Nevrax France
Date:
2000

Definition at line 60 of file inet_address.h.


Constructor & Destructor Documentation

NLNET::CInetAddress::CInetAddress ( )
 

Default Constructor. The address is set to INADDR_ANY.

Definition at line 62 of file inet_address.cpp.

NLNET::CInetAddress::CInetAddress ( const std::string & hostName,
uint16 port )
 

Alternate constructor (calls setByName()).

Definition at line 75 of file inet_address.cpp.

NLNET::CInetAddress::CInetAddress ( const std::string & hostNameAndPort )
 

Alternate constructor (calls setByName()) example: CInetAddress("www.nevrax.com:80").

Definition at line 87 of file inet_address.cpp.

NLNET::CInetAddress::CInetAddress ( const CInetAddress & other )
 

Copy constructor.

Definition at line 111 of file inet_address.cpp.

NLNET::CInetAddress::~CInetAddress ( )
 

Destructor.

Definition at line 186 of file inet_address.cpp.


Member Function Documentation

std::string NLNET::CInetAddress::asIPString ( ) const
 

Returns IP address and port as a string.

Definition at line 337 of file inet_address.cpp.

std::string NLNET::CInetAddress::asString ( ) const
 

Returns hostname and port as a string.

Definition at line 326 of file inet_address.cpp.

const string & NLNET::CInetAddress::hostName ( ) const
 

Returns hostname.

Definition at line 308 of file inet_address.cpp.

void NLNET::CInetAddress::init ( void ) [private]
 

Definition at line 173 of file inet_address.cpp.

uint32 NLNET::CInetAddress::internalIPAddress ( ) const
 

Returns internal IP address.

Definition at line 287 of file inet_address.cpp.

string NLNET::CInetAddress::ipAddress ( ) const
 

Returns readable IP address.

Definition at line 296 of file inet_address.cpp.

bool NLNET::CInetAddress::isValid ( ) const
 

Returns if object (address and port) is valid.

Definition at line 269 of file inet_address.cpp.

CInetAddress NLNET::CInetAddress::localHost ( ) [static]
 

Creates a CInetAddress object with local host address, port=0.

Definition at line 359 of file inet_address.cpp.

CInetAddress & NLNET::CInetAddress::operator= ( const CInetAddress & other )
 

Assignment operator.

Definition at line 124 of file inet_address.cpp.

uint16 NLNET::CInetAddress::port ( ) const
 

Returns port.

Definition at line 317 of file inet_address.cpp.

void NLNET::CInetAddress::serial ( NLMISC::IStream & s )
 

Serialize.

Definition at line 348 of file inet_address.cpp.

CInetAddress & NLNET::CInetAddress::setByName ( const std::string & hostName )
 

Resolves a name.

Definition at line 196 of file inet_address.cpp.

void NLNET::CInetAddress::setPort ( uint16 port )
 

Sets port.

Definition at line 234 of file inet_address.cpp.

void NLNET::CInetAddress::setSockAddr ( const sockaddr_in * saddr )
 

Sets internal socket address directly (contents is copied).

It also retrieves the host name if CInetAddress::RetrieveNames is true.

Definition at line 244 of file inet_address.cpp.

const sockaddr_in * NLNET::CInetAddress::sockAddr ( ) const
 

Returns internal socket address (read only).

Definition at line 278 of file inet_address.cpp.


Friends And Related Function Documentation

bool operator< ( const CInetAddress & a1,
const CInetAddress & a2 ) [friend]
 

Comparison < operator.

Definition at line 146 of file inet_address.cpp.

bool operator== ( const CInetAddress & a1,
const CInetAddress & a2 ) [friend]
 

Comparison == operator.

Definition at line 136 of file inet_address.cpp.


Member Data Documentation

bool NLNET::CInetAddress::RetrieveNames = true [static]
 

If true, setSockAddr() always tries to retrieve the host name from the address.

Definition at line 56 of file inet_address.cpp.

std::string NLNET::CInetAddress::_HostName [private]
 

Definition at line 137 of file inet_address.h.

sockaddr_in * NLNET::CInetAddress::_SockAddr [private]
 

Definition at line 138 of file inet_address.h.

bool NLNET::CInetAddress::_Valid [private]
 

Definition at line 139 of file inet_address.h.


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