Wizard Engine
2D cross-platform game engine built around SDL2
 
Loading...
Searching...
No Matches
wze::net Class Referencefinal

Network modul. More...

#include <net.hpp>

Public Member Functions

 net ()=delete
 Deleted explicit constructor.
 

Static Public Member Functions

static ipv4 resolve (std::string const &hostname, uint16_t port=0)
 Resolves a hostname to a wze::ipv4 address.
 
static std::string resolve (ipv4 const &address)
 Resolves an wze::ipv4 address to a hostname.
 

Detailed Description

Network modul.

See also
socket
udp_socket
tcp_socket

Definition at line 47 of file net.hpp.

Member Function Documentation

◆ resolve() [1/2]

wze::ipv4 wze::net::resolve ( std::string const & hostname,
uint16_t port = 0 )
staticnodiscard

Resolves a hostname to a wze::ipv4 address.

Parameters
hostnameHostname of the server.
portPort of the server.
Returns
Resolved wze::ipv4 address.
Exceptions
wze::exceptionHostname cannot be resolved.

Definition at line 35 of file net.cpp.

35 {
36 ipv4 address{};
37 if ((bool)SDLNet_ResolveHost(&address, hostname.c_str(), port)) {
38 throw exception<net_error>{{SDLNet_GetError()}};
39 }
40 return {address};
41}
IPaddress ipv4
IPv4 address.
Definition net.hpp:39

◆ resolve() [2/2]

std::string wze::net::resolve ( ipv4 const & address)
staticnodiscard

Resolves an wze::ipv4 address to a hostname.

Parameters
addresswze::ipv4 address of the server.
Returns
Resolved hostname.
Exceptions
wze::exceptionwze::ipv4 address cannot be resolved.

Definition at line 43 of file net.cpp.

43 {
44 char const* hostname{SDLNet_ResolveIP(&address)};
45 if (!(bool)hostname) {
46 throw exception<net_error>{{SDLNet_GetError()}};
47 }
48 return {hostname};
49}

The documentation for this class was generated from the following files: