Panda3D
Public Member Functions | List of all 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...

Public Member Functions

 __init__ ()
 Constructs an unspecified address. More...
 
 __init__ (const NetAddress)
 
 __init__ (const SocketAddress addr)
 Constructs an address from a given Socket_Address. More...
 
 clear ()
 Resets the NetAddress to its initial state. More...
 
const SocketAddress getAddr ()
 Returns the Socket_Address for this address. More...
 
int getHash ()
 
uint32_t getIp ()
 Returns the IP address to which this address refers, as a 32-bit integer, in host byte order. More...
 
uint8_t getIpComponent (int n)
 Returns the nth 8-bit component of the IP address. More...
 
str getIpString ()
 Returns the IP address to which this address refers, formatted as a string. More...
 
int getPort ()
 Returns the port number to which this address refers. More...
 
bool isAny ()
 Returns true if the IP address has only zeroes. More...
 
bool operator != (const NetAddress other)
 
bool operator== (const NetAddress other)
 
 output (Ostream out)
 
bool setAny (int port)
 Sets the address up to refer to a particular port, but not to any particular IP. More...
 
bool setBroadcast (int port)
 Sets the address to the broadcast address. More...
 
bool setHost (str hostname, int port)
 Sets the address up to refer to a particular port on a particular host. More...
 
bool setLocalhost (int port)
 Sets the address up to refer to a particular port, on this host. More...
 
 setPort (int port)
 Resets the port number without otherwise changing the address. More...
 

Detailed Description

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

Member Function Documentation

◆ __init__() [1/3]

__init__ ( )

Constructs an unspecified address.

◆ __init__() [2/3]

__init__ ( const  NetAddress)

◆ __init__() [3/3]

__init__ ( const SocketAddress  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.

◆ clear()

clear ( )

Resets the NetAddress to its initial state.

◆ getAddr()

const SocketAddress getAddr ( )

Returns the Socket_Address for this address.

◆ getHash()

int getHash ( )

◆ getIp()

uint32_t getIp ( )

Returns the IP address to which this address refers, as a 32-bit integer, in host byte order.

◆ getIpComponent()

uint8_t getIpComponent ( int  n)

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.

◆ getIpString()

str getIpString ( )

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

◆ getPort()

int getPort ( )

Returns the port number to which this address refers.

◆ isAny()

bool isAny ( )

Returns true if the IP address has only zeroes.

◆ operator !=()

bool operator != ( const NetAddress  other)

◆ operator==()

bool operator== ( const NetAddress  other)

◆ output()

output ( Ostream  out)

◆ setAny()

bool setAny ( 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).

◆ setBroadcast()

bool setBroadcast ( int  port)

Sets the address to the broadcast address.

◆ setHost()

bool setHost ( str  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.

◆ setLocalhost()

bool setLocalhost ( int  port)

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

◆ setPort()

setPort ( int  port)

Resets the port number without otherwise changing the address.