#include <NetAddress.h>
Enumerator |
---|
DEFAULT_ADAPTER_HOST |
Use the host portion of the IP address of the default adapter on this machine.
|
Definition: NetAddress.h:39
SOCKADDR_IN addr
Definition: NetAddress.h:30
G3D::NetAddress::NetAddress |
( |
const struct in_addr & |
addr, |
|
|
uint16 |
port = 0 |
|
) |
| |
|
private |
SOCKADDR_IN addr
Definition: NetAddress.h:30
void init(uint32 host, uint16 port)
Definition: NetAddress.cpp:50
uint16 port() const
Definition: NetAddress.h:91
G3D::NetAddress::NetAddress |
( |
uint32 |
host, |
|
|
uint16 |
port = 0 |
|
) |
| |
|
explicit |
In host byte order.
- See also
- DEFAULT_ADAPTER_HOST
void init(uint32 host, uint16 port)
Definition: NetAddress.cpp:50
uint16 port() const
Definition: NetAddress.h:91
G3D::NetAddress::NetAddress |
( |
const std::string & |
hostname, |
|
|
uint16 |
port |
|
) |
| |
- Parameters
-
port | Specified in host byte order (i.e., don't worry about endian issues) |
void init(uint32 host, uint16 port)
Definition: NetAddress.cpp:50
uint16 port() const
Definition: NetAddress.h:91
std::string hostname() const
G3D::NetAddress::NetAddress |
( |
const std::string & |
hostnameAndPort | ) |
|
|
explicit |
- Parameters
-
hostnameAndPort | in the form "hostname:port" or "ip:port" |
115 Array<std::string> part =
stringSplit(hostnameAndPort,
':');
118 init(part[0], atoi(part[1].c_str()));
void init(uint32 host, uint16 port)
Definition: NetAddress.cpp:50
#define debugAssert(exp)
Definition: debugAssert.h:160
G3D::Array< std::string > stringSplit(const std::string &x, char splitChar)
Definition: stringutils.cpp:230
G3D::NetAddress::NetAddress |
( |
| ) |
|
SOCKADDR_IN addr
Definition: NetAddress.h:30
static void memset(void *dst, uint8 value, size_t numBytes)
Definition: System.cpp:695
Creates a UDP broadcast address for use with a G3D::LightweightConduit.
- Deprecated:
- Use G3D::NetworkDevice::broadcastAddressArray()
UDP broadcast allows one machine to send a packet to all machines on the same local network. The IP portion of the address is 0xFFFFFFFF, which indicates "broadcast" to the underlying socket API. This feature is not available with the connection-based TCP protocol abstracted by G3D::ReliableConduit; use multisend instead.
NetAddress()
Definition: NetAddress.cpp:46
uint16 port() const
Definition: NetAddress.h:91
static NetworkDevice * instance()
Definition: NetworkDevice.cpp:109
void G3D::NetAddress::deserialize |
( |
class BinaryInput & |
b | ) |
|
void init(uint32 host, uint16 port)
Definition: NetAddress.cpp:50
uint32_t uint32
Definition: Define.h:150
uint16_t uint16
Definition: Define.h:151
std::string G3D::NetAddress::hostname |
( |
| ) |
const |
Name of this address, without the domain. Performs reverse DNS lookup on this address. This may make a network connection to a DNS server and block until that communication completes if the address is one that has not been recently checked.
Host byte order
51 if ((host != 0) || (
port != 0)) {
52 addr.sin_family = AF_INET;
57 addr.sin_addr.s_addr = htonl(host);
SOCKADDR_IN addr
Definition: NetAddress.h:30
static void memset(void *dst, uint8 value, size_t numBytes)
Definition: System.cpp:695
uint16 port() const
Definition: NetAddress.h:91
void G3D::NetAddress::init |
( |
const std::string & |
hostname, |
|
|
uint16 |
port |
|
) |
| |
|
private |
84 if (addr == INADDR_NONE) {
86 struct hostent* host = gethostbyname(
hostname.c_str());
96 if (addr != INADDR_NONE) {
SOCKADDR_IN addr
Definition: NetAddress.h:30
static void memcpy(void *dst, const void *src, size_t numBytes)
Definition: System.cpp:643
arena_t NULL
Definition: jemalloc_internal.h:624
void init(uint32 host, uint16 port)
Definition: NetAddress.cpp:50
uint32_t uint32
Definition: Define.h:150
uint16 port() const
Definition: NetAddress.h:91
std::string hostname() const
uint32 G3D::NetAddress::ip |
( |
| ) |
const |
|
inline |
Returns a value in host format (i.e., don't worry about endian issues)
87 return ntohl(
addr.sin_addr.s_addr);
SOCKADDR_IN addr
Definition: NetAddress.h:30
std::string G3D::NetAddress::ipString |
( |
| ) |
const |
181 return format(
"%s", inet_ntoa(*(in_addr*)&(
addr.sin_addr)));
SOCKADDR_IN addr
Definition: NetAddress.h:30
std::string __cdecl format(const char *fmt...) G3D_CHECK_PRINTF_ARGS
140 if (gethostname(ac,
sizeof(ac)) == SOCKET_ERROR) {
145 struct hostent* phe = gethostbyname(ac);
151 for (
int i = 0; (phe->h_addr_list[i] != 0); ++i) {
153 memcpy(&
addr, phe->h_addr_list[i],
sizeof(
struct in_addr));
SOCKADDR_IN addr
Definition: NetAddress.h:30
NetAddress()
Definition: NetAddress.cpp:46
void __cdecl printf(const char *fmt,...) G3D_CHECK_PRINTF_METHOD_ARGS
Definition: Log.cpp:119
static Log * common()
Definition: Log.cpp:100
static std::string G3D::NetAddress::localHostname |
( |
| ) |
|
|
static |
Name of the local machine machine, without the domain. The value is cached after the first call.
bool G3D::NetAddress::ok |
( |
| ) |
const |
Returns true if this is not an illegal address.
176 return addr.sin_family != 0;
SOCKADDR_IN addr
Definition: NetAddress.h:30
uint16 G3D::NetAddress::port |
( |
| ) |
const |
|
inline |
92 return ntohs(
addr.sin_port);
SOCKADDR_IN addr
Definition: NetAddress.h:30
void G3D::NetAddress::serialize |
( |
class BinaryOutput & |
b | ) |
const |
160 b.writeUInt16(
port());
uint32 ip() const
Returns a value in host format (i.e., don't worry about endian issues)
Definition: NetAddress.h:86
uint16 port() const
Definition: NetAddress.h:91
std::string G3D::NetAddress::toString |
( |
| ) |
const |
SOCKADDR_IN addr
Definition: NetAddress.h:30
std::string ipString() const
Definition: NetAddress.cpp:180
std::string __cdecl format(const char *fmt...) G3D_CHECK_PRINTF_ARGS
The documentation for this class was generated from the following files: