vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
Vkm::Engine::NetAddress Struct Reference

Where a datagram came from, or is going to: an IPv4 host and a port. More...

#include <net_address.h>

Public Member Functions

 operator bool () const
 True when this names somewhere - a zero address is the null one.
std::string toString () const
 "127.0.0.1:27015", for a log line or a readout.

Static Public Member Functions

static NetAddress parse (const std::string &text, uint16_t fallbackPort=0)
 Read "host:port", or "host" with fallbackPort.
static bool parsePort (const std::string &text, uint16_t &port)
 Read a port: decimal digits and nothing else, 1 to 65535.

Public Attributes

uint32_t ipv4 = 0
 Host byte order: 0x7F000001 is 127.0.0.1.

Detailed Description

Where a datagram came from, or is going to: an IPv4 host and a port.

Host byte order; converted at the socket.

Member Function Documentation

◆ parse()

NetAddress Vkm::Engine::NetAddress::parse ( const std::string & text,
uint16_t fallbackPort = 0 )
static

Read "host:port", or "host" with fallbackPort.

A caller passes the project's port as the fallback. A name that is not dotted quad goes through the system resolver.

Parameters
textHost, or host:port.
fallbackPortUsed when text carries no port.
Returns
The address, or a null one when text names nowhere.

◆ parsePort()

bool Vkm::Engine::NetAddress::parsePort ( const std::string & text,
uint16_t & port )
static

Read a port: decimal digits and nothing else, 1 to 65535.

Refused whole: "27015x" is not 27015, which they did not ask for.

Parameters
textThe digits.
portSet only when text is a port.
Returns
False when text is not one.

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