RakNet  4.0
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
RakNet::SystemAddress Struct Reference

Network address for a system. More...

#include <RakNetTypes.h>

Public Member Functions

 SystemAddress ()
 Constructors.
 
unsigned char GetIPVersion (void) const
 
void SetToLoopback (void)
 Call SetToLoopback(), with whatever IP version is currently held. Defaults to IPV4.
 
void SetToLoopback (unsigned char ipVersion)
 
bool IsLoopback (void) const
 
bool FromString (const char *str, char portDelineator='|', int ipVersion=0)
 
bool FromStringExplicitPort (const char *str, unsigned short port, int ipVersion=0)
 Same as FromString(), but you explicitly set a port at the same time.
 
void CopyPort (const SystemAddress &right)
 Copy the port from another SystemAddress structure.
 
bool EqualsExcludingPort (const SystemAddress &right) const
 Returns if two system addresses have the same IP (port is not checked)
 
unsigned short GetPort (void) const
 Returns the port in host order (this is what you normally use)
 
void SetPortHostOrder (unsigned short s)
 
bool SetBinaryAddress (const char *str, char portDelineator=':')
 Old version, for crap platforms that don't support newer socket functions.
 
void ToString_Old (bool writePort, char *dest, char portDelineator=':') const
 Old version, for crap platforms that don't support newer socket functions.
 

Static Public Member Functions

static unsigned long ToInteger (const SystemAddress &sa)
 Hash the system address.
 

Public Attributes

union sockaddr_in addr4
 SystemAddress, with RAKNET_SUPPORT_IPV6 defined, holds both an sockaddr_in6 and a sockaddr_in.
 
unsigned short debugPort
 This is not used internally, but holds a copy of the port held in the address union, so for debugging it's easier to check what port is being held.
 

Detailed Description

Network address for a system.

Corresponds to a network address
This is not necessarily a unique identifier. For example, if a system has both LAN and internet connections, the system may be identified by either one, depending on who is communicating
Therefore, you should not transmit the SystemAddress over the network and expect it to identify a system, or use it to connect to that system, except in the case where that system is not behind a NAT (such as with a dedciated server) Use RakNetGUID for a unique per-instance of RakPeer to identify systems

Member Function Documentation

bool RakNet::SystemAddress::FromString ( const char *  str,
char  portDelineator = '|',
int  ipVersion = 0 
)

Set the system address from a printable IP string, for example "192.0.2.1" or "2001:db8:63b3:1::3490" You can write the port as well, using the portDelineator, for example "192.0.2.1|1234"

Parameters
[in]strA printable IP string, for example "192.0.2.1" or "2001:db8:63b3:1::3490". Pass 0 for str to set to UNASSIGNED_SYSTEM_ADDRESS
[in]portDelineatorif str contains a port, delineate the port with this character. portDelineator should not be '.', ':', '', '-', '/', a number, or a-f
[in]ipVersionOnly used if str is a pre-defined address in the wrong format, such as 127.0.0.1 but you want ip version 6, so you can pass 6 here to do the conversion
Note
The current port is unchanged if a port is not specified in str
Returns
True on success, false on ipVersion does not match type of passed string
unsigned char RakNet::SystemAddress::GetIPVersion ( void  ) const

Return the IP version, either IPV4 or IPV6

Returns
Either 4 or 6
bool RakNet::SystemAddress::IsLoopback ( void  ) const
Returns
If was set to 127.0.0.1 or ::1
void RakNet::SystemAddress::SetPortHostOrder ( unsigned short  s)

Sets the port. The port value should be in host order (this is what you normally use) Renamed from SetPort because of winspool.h http://edn.embarcadero.com/article/21494

void RakNet::SystemAddress::SetToLoopback ( unsigned char  ipVersion)

Call SetToLoopback() with a specific IP version

Parameters
[in]ipVersionEither 4 for IPV4 or 6 for IPV6

The documentation for this struct was generated from the following file: