Panda3D
|
Represents a network address to which UDP packets may be sent or to which a TCP socket may be bound. More...
#include "netAddress.h"
Public Member Functions | |
NetAddress () | |
Constructs an unspecified address. | |
NetAddress (const Socket_Address &addr) | |
Constructs an address from a given Socket_Address. | |
void | clear () |
Resets the NetAddress to its initial state. | |
const Socket_Address & | get_addr () const |
Returns the Socket_Address for this address. | |
PN_uint32 | get_ip () const |
Returns the IP address to which this address refers, as a 32-bit integer, in host byte order. | |
PN_uint8 | get_ip_component (int n) const |
Returns the nth 8-bit component of the IP address. | |
string | get_ip_string () const |
Returns the IP address to which this address refers, formatted as a string. | |
int | get_port () const |
Returns the port number to which this address refers. | |
void | output (ostream &out) const |
bool | set_any (int port) |
Sets the address up to refer to a particular port, but not to any particular IP. | |
bool | set_host (const string &hostname, int port) |
Sets the address up to refer to a particular port on a particular host. | |
bool | set_localhost (int port) |
Sets the address up to refer to a particular port, on this host. | |
void | set_port (int port) |
Resets the port number without otherwise changing the address. |
Represents a network address to which UDP packets may be sent or to which a TCP socket may be bound.
Definition at line 27 of file netAddress.h.
NetAddress::NetAddress | ( | ) |
Constructs an unspecified address.
Definition at line 25 of file netAddress.cxx.
NetAddress::NetAddress | ( | const Socket_Address & | addr | ) |
Constructs an address from a given Socket_Address.
Normally, this constructor should not be used by user code; instead, create a default NetAddress and use one of the set_*() functions to set up an address.
Definition at line 37 of file netAddress.cxx.
void NetAddress::clear | ( | ) |
Resets the NetAddress to its initial state.
Definition at line 83 of file netAddress.cxx.
References Socket_Address::clear().
Referenced by NetDatagram::clear().
const Socket_Address & NetAddress::get_addr | ( | ) | const |
Returns the Socket_Address for this address.
Definition at line 153 of file netAddress.cxx.
PN_uint32 NetAddress::get_ip | ( | ) | const |
Returns the IP address to which this address refers, as a 32-bit integer, in host byte order.
Definition at line 126 of file netAddress.cxx.
References Socket_Address::GetIPAddressRaw().
PN_uint8 NetAddress::get_ip_component | ( | int | n | ) | const |
Returns the nth 8-bit component of the IP address.
An IP address has four components; component 0 is the first (leftmost), and component 3 is the last (rightmost) in the dotted number convention.
Definition at line 139 of file netAddress.cxx.
References Socket_Address::GetIPAddressRaw().
string NetAddress::get_ip_string | ( | ) | const |
Returns the IP address to which this address refers, formatted as a string.
Definition at line 115 of file netAddress.cxx.
References Socket_Address::get_ip().
Referenced by ConnectionListener::process_incoming_data().
int NetAddress::get_port | ( | ) | const |
Returns the port number to which this address refers.
Definition at line 93 of file netAddress.cxx.
References Socket_Address::get_port().
bool NetAddress::set_any | ( | int | port | ) |
Sets the address up to refer to a particular port, but not to any particular IP.
Returns true if successful, false otherwise (currently, this only returns true).
Definition at line 50 of file netAddress.cxx.
References Socket_Address::set_any_IP().
bool NetAddress::set_host | ( | const string & | hostname, |
int | port | ||
) |
Sets the address up to refer to a particular port on a particular host.
Returns true if the hostname is known, false otherwise.
Definition at line 73 of file netAddress.cxx.
References Socket_Address::set_host().
bool NetAddress::set_localhost | ( | int | port | ) |
Sets the address up to refer to a particular port, on this host.
Definition at line 61 of file netAddress.cxx.
References Socket_Address::set_host().
void NetAddress::set_port | ( | int | port | ) |
Resets the port number without otherwise changing the address.
Definition at line 104 of file netAddress.cxx.
References Socket_Address::set_port().