CL_SocketName Class Reference
[clanNetwork Socket]

Socket name; container class for an IP address and port. More...

#include <socket_name.h>

List of all members.

Public Member Functions

Construction

 CL_SocketName ()
 Constructs a new socket name.
 CL_SocketName (const CL_String &port)
 Constructs a SocketName.
 CL_SocketName (const CL_String &address, const CL_String &port)
 Constructs a SocketName.
Attributes

CL_String get_address () const
 Returns the address part of the socket name.
CL_String get_port () const
 Returns the port part of the socket name.
bool operator== (const CL_SocketName &other_instance) const
 Returns true if objects are the same.
bool operator< (const CL_SocketName &other_instance) const
 Returns true if the other address is less.
bool operator> (const CL_SocketName &other_instance) const
 Returns true if the other address is greater.
Operations

void set_name (const CL_String &hostname, const CL_String &port)
 Set the socket name using a hostname and port.
void set_address (const CL_String &address)
 Set the IP address.
void set_port (const CL_String &port)
 Set the IP port.
CL_String lookup_ipv4 () const
 Perform a DNS lookup, if needed, for the IP v4 address.
CL_String lookup_hostname () const
 Perform a DNS lookup, if needed, for the hostname.
CL_SocketName to_ipv4 ()
 Create socket name that uses the IP v4 address as its address.
CL_SocketName to_hostname ()
 Create socket name that uses the hostname as its address.
void to_sockaddr (int domain, struct sockaddr *addr, int len) const
 Fill the socket name into a C sockets sockaddr structure.
void from_sockaddr (int domain, struct sockaddr *addr, int len)
 Get the socket name from a C sockets sockaddr structure.

Detailed Description

Socket name; container class for an IP address and port.


Constructor & Destructor Documentation

CL_SocketName::CL_SocketName (  ) 

Constructs a new socket name.

If no address is specified, the socket address will default to INADDR_ANY. If no port is specified, it will default to port 0.

CL_SocketName::CL_SocketName ( const CL_String port  ) 

Constructs a SocketName.

Parameters:
port = String
CL_SocketName::CL_SocketName ( const CL_String address,
const CL_String port 
)

Constructs a SocketName.

Parameters:
address = String
port = String

Member Function Documentation

void CL_SocketName::from_sockaddr ( int  domain,
struct sockaddr *  addr,
int  len 
)

Get the socket name from a C sockets sockaddr structure.

CL_String CL_SocketName::get_address (  )  const

Returns the address part of the socket name.

CL_String CL_SocketName::get_port (  )  const

Returns the port part of the socket name.

CL_String CL_SocketName::lookup_hostname (  )  const

Perform a DNS lookup, if needed, for the hostname.

CL_String CL_SocketName::lookup_ipv4 (  )  const

Perform a DNS lookup, if needed, for the IP v4 address.

bool CL_SocketName::operator< ( const CL_SocketName other_instance  )  const

Returns true if the other address is less.

This is used for sorting purposes (eg. if you use a std::map<CL_SocketName, CL_Socket>), and sorts the address based on lowest IP number address.

bool CL_SocketName::operator== ( const CL_SocketName other_instance  )  const

Returns true if objects are the same.

bool CL_SocketName::operator> ( const CL_SocketName other_instance  )  const

Returns true if the other address is greater.

This is used for sorting purposes (eg. if you use a std::map<CL_SocketName, CL_Socket>), and sorts the address based on lowest IP number address.

void CL_SocketName::set_address ( const CL_String address  ) 

Set the IP address.

void CL_SocketName::set_name ( const CL_String hostname,
const CL_String port 
)

Set the socket name using a hostname and port.

Parameters:
hostname Can be an IPv4 dotted-quad, hostname or a valid IPv6 address.
port Port number.
void CL_SocketName::set_port ( const CL_String port  ) 

Set the IP port.

CL_SocketName CL_SocketName::to_hostname (  ) 

Create socket name that uses the hostname as its address.

CL_SocketName CL_SocketName::to_ipv4 (  ) 

Create socket name that uses the IP v4 address as its address.

void CL_SocketName::to_sockaddr ( int  domain,
struct sockaddr *  addr,
int  len 
) const

Fill the socket name into a C sockets sockaddr structure.


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