Panda3D
Public Member Functions | List of all members
Socket_Address Class Reference

A simple place to store and manipulate tcp and port address for communication layer. More...

#include "socket_address.h"

Public Member Functions

 Socket_Address (const struct sockaddr &inaddr)
 
 Socket_Address (const struct sockaddr_in &inaddr)
 
 Socket_Address (const struct sockaddr_in6 &inaddr)
 
 Socket_Address (const struct sockaddr_storage &inaddr)
 
 Socket_Address (unsigned short port=0)
 Constructor that lets us set a port value. More...
 
 Socket_Address (const Socket_Address &inaddr)
 
virtual ~Socket_Address ()
 Normal Destructor. More...
 
void clear ()
 Set the internal values to a suitable known value. More...
 
sa_family_t get_family () const
 Returns AF_INET if this is an IPv4 address, or AF_INET6 if this is an IPv6 address. More...
 
std::string get_ip () const
 Return the IP address portion in dot notation string. More...
 
std::string get_ip_port () const
 Return the ip address/port in dot notation string. More...
 
unsigned short get_port () const
 Get the port portion as an integer. More...
 
struct sockaddr & GetAddressInfo ()
 
const struct sockaddr & GetAddressInfo () const
 
unsigned long GetIPAddressRaw () const
 Returns a raw 32-bit unsigned integer representing the IPv4 address. More...
 
bool is_any () const
 True if the address is zero. More...
 
bool is_mcast_range () const
 True if the address is in the multicast range. More...
 
bool operator != (const Socket_Address &in) const
 
bool operator< (const Socket_Address &in) const
 
bool operator== (const Socket_Address &in) const
 
bool set_any_IP (unsigned short port)
 Set to any address and a specified port. More...
 
bool set_any_IPv6 (unsigned short port)
 Set to any IPv6 address and a specified port. More...
 
bool set_broadcast (unsigned short port)
 Set to the broadcast address and a specified port. More...
 
bool set_host (const std::string &hostname, unsigned short port)
 This function will take a port and string-based TCP address and initialize the address with this information. More...
 
bool set_host (const std::string &hostname)
 Initializes the address from a string specifying both the address and port, separated by a colon. More...
 
bool set_host (uint32_t ip4addr, unsigned short port)
 
bool set_port (unsigned short port)
 Set to a specified port. More...
 

Detailed Description

A simple place to store and manipulate tcp and port address for communication layer.

Definition at line 25 of file socket_address.h.

Constructor & Destructor Documentation

◆ Socket_Address()

Socket_Address::Socket_Address ( unsigned short  port = 0)
inlineexplicit

Constructor that lets us set a port value.

Definition at line 20 of file socket_address.I.

◆ ~Socket_Address()

Socket_Address::~Socket_Address ( )
inlinevirtual

Normal Destructor.

Definition at line 85 of file socket_address.I.

Member Function Documentation

◆ clear()

void Socket_Address::clear ( )
inline

Set the internal values to a suitable known value.

Definition at line 168 of file socket_address.I.

Referenced by NetAddress::clear().

◆ get_family()

sa_family_t Socket_Address::get_family ( ) const
inline

Returns AF_INET if this is an IPv4 address, or AF_INET6 if this is an IPv6 address.

Definition at line 179 of file socket_address.I.

Referenced by Socket_TCP::ActiveOpen(), Socket_TCP::ActiveOpenNonBlocking(), Socket_UDP_Incoming::OpenForInput(), Socket_UDP_Incoming::OpenForInputMCast(), and Socket_TCP_Listen::OpenForListen().

◆ get_ip()

std::string Socket_Address::get_ip ( ) const

Return the IP address portion in dot notation string.

Definition at line 90 of file socket_address.cxx.

Referenced by NetAddress::get_ip_string().

◆ get_ip_port()

std::string Socket_Address::get_ip_port ( ) const

Return the ip address/port in dot notation string.

If this is an IPv6 address, it will be enclosed in square brackets.

Definition at line 112 of file socket_address.cxx.

References get_port().

◆ get_port()

unsigned short Socket_Address::get_port ( ) const
inline

Get the port portion as an integer.

Definition at line 187 of file socket_address.I.

Referenced by get_ip_port(), NetAddress::get_port(), and Socket_UDP_Incoming::OpenForInputMCast().

◆ GetIPAddressRaw()

unsigned long Socket_Address::GetIPAddressRaw ( ) const

Returns a raw 32-bit unsigned integer representing the IPv4 address.

Definition at line 138 of file socket_address.cxx.

Referenced by NetAddress::get_ip().

◆ is_any()

bool Socket_Address::is_any ( ) const
inline

True if the address is zero.

Definition at line 235 of file socket_address.I.

Referenced by NetAddress::is_any().

◆ is_mcast_range()

bool Socket_Address::is_mcast_range ( ) const
inline

True if the address is in the multicast range.

Definition at line 251 of file socket_address.I.

◆ set_any_IP()

bool Socket_Address::set_any_IP ( unsigned short  port)
inline

Set to any address and a specified port.

Definition at line 136 of file socket_address.I.

Referenced by NetAddress::set_any().

◆ set_any_IPv6()

bool Socket_Address::set_any_IPv6 ( unsigned short  port)
inline

Set to any IPv6 address and a specified port.

Definition at line 147 of file socket_address.I.

◆ set_broadcast()

bool Socket_Address::set_broadcast ( unsigned short  port)
inline

Set to the broadcast address and a specified port.

Definition at line 125 of file socket_address.I.

Referenced by NetAddress::set_broadcast(), and set_host().

◆ set_host() [1/2]

bool Socket_Address::set_host ( const std::string &  hostname,
unsigned short  port 
)

This function will take a port and string-based TCP address and initialize the address with this information.

Returns true on success; on failure, it returns false and the address may be undefined.

Definition at line 23 of file socket_address.cxx.

References set_broadcast().

Referenced by NetAddress::set_host(), set_host(), and NetAddress::set_localhost().

◆ set_host() [2/2]

bool Socket_Address::set_host ( const std::string &  hostname)

Initializes the address from a string specifying both the address and port, separated by a colon.

An IPv6 address must be enclosed in brackets.

Definition at line 51 of file socket_address.cxx.

References set_host().

◆ set_port()

bool Socket_Address::set_port ( unsigned short  port)
inline

Set to a specified port.

Definition at line 159 of file socket_address.I.

Referenced by NetAddress::set_port().


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