Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

NetAddress Class Reference

Represents a network address to which UDP packets may be sent or to which a TCP socket may be bound. More...

#include <netAddress.h>

List of all members.

Public Member Functions

 NetAddress ()
 Constructs an unspecified address.

 NetAddress (const PRNetAddr &addr)
 Constructs an address from a given PRNetAddr.

bool set_any (int port)
 Sets the address up to refer to a particular port, but not to any particular IP.

bool set_localhost (int port)
 Sets the address up to refer to a particular port, on this host.

bool set_host (const string &hostname, int port)
 Sets the address up to refer to a particular port on a particular host.

void clear ()
 Resets the NetAddress to its initial state.

int get_port () const
 Returns the port number to which this address refers.

void set_port (int port)
 Resets the port number without otherwise changing the address.

string get_ip_string () const
 Returns the IP address to which this address refers, formatted as a string.

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.

PRNetAddr * get_addr () const
 Returns the PRNetAddr for this address.

void output (ostream &out) const

Private Attributes

PRNetAddr _addr


Detailed Description

Represents a network address to which UDP packets may be sent or to which a TCP socket may be bound.

Definition at line 39 of file netAddress.h.


Constructor & Destructor Documentation

NetAddress::NetAddress  ) 
 

Constructs an unspecified address.

Definition at line 39 of file netAddress.cxx.

NetAddress::NetAddress const PRNetAddr &  addr  ) 
 

Constructs an address from a given PRNetAddr.

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 58 of file netAddress.cxx.

References _addr.


Member Function Documentation

void NetAddress::clear  ) 
 

Resets the NetAddress to its initial state.

Definition at line 209 of file netAddress.cxx.

References _addr, and pprerror().

Referenced by NetDatagram::NetDatagram().

PRNetAddr * NetAddress::get_addr  )  const
 

Returns the PRNetAddr for this address.

Definition at line 312 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 277 of file netAddress.cxx.

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 296 of file netAddress.cxx.

string NetAddress::get_ip_string  )  const
 

Returns the IP address to which this address refers, formatted as a string.

Definition at line 252 of file netAddress.cxx.

References _addr.

Referenced by ConnectionListener::receive_datagram().

int NetAddress::get_port  )  const
 

Returns the port number to which this address refers.

Definition at line 222 of file netAddress.cxx.

void NetAddress::output ostream &  out  )  const
 

Definition at line 324 of file netAddress.cxx.

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 77 of file netAddress.cxx.

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 113 of file netAddress.cxx.

Referenced by ConnectionManager::open_TCP_client_connection().

bool NetAddress::set_localhost int  port  ) 
 

Sets the address up to refer to a particular port, on this host.

Definition at line 94 of file netAddress.cxx.

References size_t.

void NetAddress::set_port int  port  ) 
 

Resets the port number without otherwise changing the address.

Definition at line 237 of file netAddress.cxx.

References _addr, nassertr, and PN_uint8.


Member Data Documentation

PRNetAddr NetAddress::_addr [private]
 

Definition at line 61 of file netAddress.h.

Referenced by clear(), get_ip_string(), NetAddress(), and set_port().


The documentation for this class was generated from the following files:
Generated on Fri May 2 00:52:31 2003 for Panda by doxygen1.3