Cafu Engine
NetAddressT Class Reference

Network address consisting of an IP4 address and port number. More...

#include "Network.hpp"

Classes

struct  BadHostName
 Exception that is thrown on name look-up failure. More...
 

Public Member Functions

 NetAddressT (char IP0, char IP1, char IP2, char IP3, unsigned short Port_)
 Constructor. More...
 
 NetAddressT (const char *Name, unsigned short Port_)
 Constructor. More...
 
 NetAddressT (const std::string &Name, unsigned short Port_)
 Constructor. More...
 
 NetAddressT (const sockaddr_in &SockAddrIn)
 Constructor. More...
 
const char * ToString () const
 Converts the network address into a string. More...
 
sockaddr_in ToSockAddrIn () const
 Converts the network address into a sockaddr_in struct. More...
 
bool operator== (const NetAddressT &Address) const
 Compares two network addresses. More...
 
bool operator!= (const NetAddressT &Address) const
 Compares two network addresses. More...
 

Public Attributes

char IP [4]
 The IP number of the network address. More...
 
unsigned short Port
 The port number of the network address. More...
 

Detailed Description

Network address consisting of an IP4 address and port number.

Constructor & Destructor Documentation

NetAddressT::NetAddressT ( char  IP0,
char  IP1,
char  IP2,
char  IP3,
unsigned short  Port_ 
)

Constructor.

Parameters
IP0The first byte of the IP address.
IP1The second byte of the IP address.
IP2The third byte of the IP address.
IP3The fourth byte of the IP address.
Port_The port of this network adress
NetAddressT::NetAddressT ( const char *  Name,
unsigned short  Port_ 
)

Constructor.

Parameters
NameHostname from which the network address should be created.
Port_The port of this network address.
Exceptions
BadHostName
NetAddressT::NetAddressT ( const std::string &  Name,
unsigned short  Port_ 
)

Constructor.

Parameters
NameHostname from which the network address should be created.
Port_The port of this network address.
Exceptions
BadHostName
NetAddressT::NetAddressT ( const sockaddr_in &  SockAddrIn)

Constructor.

Parameters
SockAddrInsockaddr_in stuct from which this network address is created.

Member Function Documentation

bool NetAddressT::operator!= ( const NetAddressT Address) const

Compares two network addresses.

Parameters
AddressThe address to compare to.
Returns
'true' if the addresses are different.
bool NetAddressT::operator== ( const NetAddressT Address) const

Compares two network addresses.

Parameters
AddressThe address to compare to.
Returns
'true' if the addresses are the same.
sockaddr_in NetAddressT::ToSockAddrIn ( ) const

Converts the network address into a sockaddr_in struct.

Returns
The network address as sockaddr_in.
const char * NetAddressT::ToString ( ) const

Converts the network address into a string.

Returns
The network address in string format.

Member Data Documentation

char NetAddressT::IP[4]

The IP number of the network address.

unsigned short NetAddressT::Port

The port number of the network address.


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