sP2P c++ STL *nix API  1.2
NAT traversal and peer-to-peer networking API providing all utilities needed to build peer-to-peer application straigth out of box
 All Classes Functions Variables Typedefs Enumerations Enumerator
sp2plib::IPEndPoint Class Reference

Public Member Functions

 IPEndPoint (IP4Address IPAddress, sp2plib::UInt16 Port)
 Initialises new instance from IPEndPoint from IP4Address object and port value
 
 IPEndPoint (char *HostAddress, sp2plib::UInt16 Port)
 Initialises new instance from text represented host name/IP and port value
 
 IPEndPoint (sp2plib::UInt32 intAddress, sp2plib::UInt16 Port)
 Initialises new instance from address Int32 value (machine order) and port value
 
 IPEndPoint (sockaddr_in sAddr)
 Initialises new instance from sockaddr_in object
 
 IPEndPoint (const char *sEp)
 Initialises new instance from human readable text address:port value
 
 ~IPEndPoint ()
 Destructor.
 
void Set (IP4Address IPAddress, sp2plib::UInt16 Port)
 Sets the value of end point from IP4Address object and port value
 
void Set (char *HostAddress, sp2plib::UInt16 Port)
 Sets the value of end point from text represented host name/IP and port value
 
void Set (sp2plib::UInt32 intAddress, sp2plib::UInt16 Port)
 Sets the value of end point from address Int32 value (machine order) and port value
 
IP4Address GetAddress ()
 Gets address of End Point as IP4Address object
 
void As_sockaddr_in (sockaddr_in &adr)
 Injects data from this object into sockaddr_in structure
 
sockaddr_in get_sockaddr_in ()
 Gets sockaddr_in object form IPEndPoint
 
void From_sockaddr_in (const sockaddr_in &adr)
 Takes values from sockaddr_in object
 
sp2plib::UInt16 GetPort ()
 Gets the port.
 
void SetPort (sp2plib::UInt16 Port)
 Sets a port.
 
void SetAddress (sp2plib::UInt32 intAddress)
 Sets address value by passing Int32 address value (machine order) argument
 
void SetAddress (char *HostAddress)
 Sets address value by passing address in text format : d.d.d.d
 
void SetAddressFromBytes (unsigned char *AddressBytes, int startIndex=0)
 Sets address value from 4 byte sequence argument. To specify start index of sequence different than 0 use startIndex argument
 
::std::string ToString ()
 Gets human readable form of IPEndPoint in format d.d.d.d:p
 
bool Equals (IPEndPoint *otherEndPoint)
 Tests if this IPEndPoint * is considered equal to another.
 
void ParseFromBytes (unsigned char *buffer, int startIndex=0)
 Parses 6 (address[4]:port[2]) bytes from byte array in machine order
 
void ToByteArray (unsigned char *buffer, int startIndex=0)
 Writes 6 (address[4]:port[2]) bytes to existing byte array starting from startIndex
 
 operator sockaddr_in ()
 sockaddr_in casting operator.
 
IPEndPointoperator= (const IPEndPoint &rhs)
 Assignment operator.
 
IPEndPointoperator= (const sockaddr_in &rhs)
 Assignment operator.
 
bool operator== (const IPEndPoint &other) const
 Equality operator.
 
bool operator!= (const IPEndPoint &other) const
 Inequality operator.
 

Static Public Member Functions

static IPEndPointnew_ParseFromBytes (unsigned char *buffer, int startIndex=0)
 Creates IPEndPoint object from byte array
 
static IPEndPointANY ()
 Gets Ep = 0.0.0.0:0 (ANY)
 

Constructor & Destructor Documentation

sp2plib::IPEndPoint::IPEndPoint ( IP4Address  IPAddress,
sp2plib::UInt16  Port 
)

Initialises new instance from IPEndPoint from IP4Address object and port value

Parameters
IPAddressThe IP address.
PortThe port.
sp2plib::IPEndPoint::IPEndPoint ( char *  HostAddress,
sp2plib::UInt16  Port 
)

Initialises new instance from text represented host name/IP and port value

Parameters
HostAddressThe host address in human readable format or dns format
PortThe port.
sp2plib::IPEndPoint::IPEndPoint ( sp2plib::UInt32  intAddress,
sp2plib::UInt16  Port 
)

Initialises new instance from address Int32 value (machine order) and port value

Parameters
intAddressThe int address in machine byte order
PortThe port.
sp2plib::IPEndPoint::IPEndPoint ( sockaddr_in  sAddr)

Initialises new instance from sockaddr_in object

Parameters
sAddrThe sockaddr_in address
sp2plib::IPEndPoint::IPEndPoint ( const char *  sEp)

Initialises new instance from human readable text address:port value

Parameters
sEpHuman readable string 000.000.000.000:00000
sp2plib::IPEndPoint::~IPEndPoint ( )

Destructor.

Member Function Documentation

static IPEndPoint& sp2plib::IPEndPoint::ANY ( )
static

Gets Ep = 0.0.0.0:0 (ANY)

Returns
IPEndPoint = ANY(0.0.0.0:0)
void sp2plib::IPEndPoint::As_sockaddr_in ( sockaddr_in &  adr)

Injects data from this object into sockaddr_in structure

Parameters
adrThe sockaddr_in address.
bool sp2plib::IPEndPoint::Equals ( IPEndPoint otherEndPoint)

Tests if this IPEndPoint * is considered equal to another.

Parameters
otherEndPoint[in,out] If non-null, the IP end point * to compare to this object.
Returns
true if the objects are considered equal, false if they are not.
void sp2plib::IPEndPoint::From_sockaddr_in ( const sockaddr_in &  adr)

Takes values from sockaddr_in object

Parameters
adrThe sockaddr_in address.
sockaddr_in sp2plib::IPEndPoint::get_sockaddr_in ( )

Gets sockaddr_in object form IPEndPoint

Returns
The sockaddr_in.
IP4Address sp2plib::IPEndPoint::GetAddress ( )

Gets address of End Point as IP4Address object

Returns
The address.
sp2plib::UInt16 sp2plib::IPEndPoint::GetPort ( )

Gets the port.

Returns
The port.
static IPEndPoint* sp2plib::IPEndPoint::new_ParseFromBytes ( unsigned char *  buffer,
int  startIndex = 0 
)
static

Creates IPEndPoint object from byte array

Parameters
bufferThe buffer holding 6 EP bytes
startIndex(optional) the start index from which to start parsing.
Returns
null if it fails, else.

char b_adr[6] = {0x0C,0x0D,0x0E,0x0F,0x0A,0x0A}; IPEndPoint *adr = IPEndPoint::new_ParseFromBytes(b_adr);

sp2plib::IPEndPoint::operator sockaddr_in ( )

sockaddr_in casting operator.

bool sp2plib::IPEndPoint::operator!= ( const IPEndPoint other) const

Inequality operator.

Parameters
otherThe other.
Returns
true if the parameters are not considered equivalent.
IPEndPoint& sp2plib::IPEndPoint::operator= ( const IPEndPoint rhs)

Assignment operator.

Parameters
rhsThe right hand side.
Returns
A shallow copy of this object.
IPEndPoint& sp2plib::IPEndPoint::operator= ( const sockaddr_in &  rhs)

Assignment operator.

Parameters
rhsThe right hand side.
Returns
A shallow copy of this object.
bool sp2plib::IPEndPoint::operator== ( const IPEndPoint other) const

Equality operator.

Parameters
otherThe other.
Returns
true if the parameters are considered equivalent.
void sp2plib::IPEndPoint::ParseFromBytes ( unsigned char *  buffer,
int  startIndex = 0 
)

Parses 6 (address[4]:port[2]) bytes from byte array in machine order

Parameters
bufferThe buffer holding 6 EP bytes.
startIndex(optional) the start index from which to start parsing.
void sp2plib::IPEndPoint::Set ( IP4Address  IPAddress,
sp2plib::UInt16  Port 
)

Sets the value of end point from IP4Address object and port value

Parameters
IPAddressThe IP address.
PortThe port.
void sp2plib::IPEndPoint::Set ( char *  HostAddress,
sp2plib::UInt16  Port 
)

Sets the value of end point from text represented host name/IP and port value

Parameters
HostAddressThe host address in human readable format or dns format.
PortThe port.
void sp2plib::IPEndPoint::Set ( sp2plib::UInt32  intAddress,
sp2plib::UInt16  Port 
)

Sets the value of end point from address Int32 value (machine order) and port value

Parameters
intAddressThe int address in machine byte order.
PortThe port.
void sp2plib::IPEndPoint::SetAddress ( sp2plib::UInt32  intAddress)

Sets address value by passing Int32 address value (machine order) argument

Parameters
intAddressThe int address in machine byte order.
void sp2plib::IPEndPoint::SetAddress ( char *  HostAddress)

Sets address value by passing address in text format : d.d.d.d

Parameters
HostAddressThe host address in human readable format or dns format.
void sp2plib::IPEndPoint::SetAddressFromBytes ( unsigned char *  AddressBytes,
int  startIndex = 0 
)

Sets address value from 4 byte sequence argument. To specify start index of sequence different than 0 use startIndex argument

Parameters
AddressBytesArray holding address bytes
startIndex(optional) the start index from which to start parsing
void sp2plib::IPEndPoint::SetPort ( sp2plib::UInt16  Port)

Sets a port.

Parameters
PortThe port.
void sp2plib::IPEndPoint::ToByteArray ( unsigned char *  buffer,
int  startIndex = 0 
)

Writes 6 (address[4]:port[2]) bytes to existing byte array starting from startIndex

Parameters
bufferThe buffer to store 6 EP bytes to
startIndex(optional) the start index from which to start writing
::std::string sp2plib::IPEndPoint::ToString ( )

Gets human readable form of IPEndPoint in format d.d.d.d:p


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