ClanLib  2.3.7
List of all members
CL_SocketName Class Reference

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

#include <socket_name.h>

Public Member Functions

Construction
 CL_SocketName ()
 Constructs a new socket name. More...
 
 CL_SocketName (const CL_String &port)
 Constructs a SocketName. More...
 
 CL_SocketName (const CL_String &address, const CL_String &port)
 Constructs a SocketName. More...
 
Attributes
CL_String get_address () const
 Returns the address part of the socket name. More...
 
CL_String get_port () const
 Returns the port part of the socket name. More...
 
bool operator== (const CL_SocketName &other_instance) const
 Returns true if objects are the same. More...
 
bool operator< (const CL_SocketName &other_instance) const
 Returns true if the other address is less. More...
 
bool operator> (const CL_SocketName &other_instance) const
 Returns true if the other address is greater. More...
 
Operations
void set_name (const CL_String &hostname, const CL_String &port)
 Set the socket name using a hostname and port. More...
 
void set_address (const CL_String &address)
 Set the IP address. More...
 
void set_port (const CL_String &port)
 Set the IP port. More...
 
CL_String lookup_ipv4 () const
 Perform a DNS lookup, if needed, for the IP v4 address. More...
 
CL_String lookup_hostname () const
 Perform a DNS lookup, if needed, for the hostname. More...
 
CL_SocketName to_ipv4 ()
 Create socket name that uses the IP v4 address as its address. More...
 
CL_SocketName to_hostname ()
 Create socket name that uses the hostname as its address. More...
 
void to_sockaddr (int domain, struct sockaddr *addr, int len) const
 Fill the socket name into a C sockets sockaddr structure. More...
 
void from_sockaddr (int domain, struct sockaddr *addr, int len)
 Get the socket name from a C sockets sockaddr structure. More...
 

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
hostnameCan be an IPv4 dotted-quad, hostname or a valid IPv6 address.
portPort 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: