Sane C++ Libraries
C++ Platform Abstraction Libraries
SC::SocketDNS Struct Reference

Synchronous DNS Resolution. More...

#include <Socket.h>

Static Public Member Functions

static Result resolveDNS (SpanStringView host, SpanString &ipAddress)
 Resolve an host string to an ip address (blocking until DNS response arrives) More...
 

Detailed Description

Synchronous DNS Resolution.

Example:

char buffer[256] = {0};
SpanString ipAddress = buffer;
SC_TEST_EXPECT(SocketDNS::resolveDNS("localhost", ipAddress));
SC_TEST_EXPECT(StringView(ipAddress.text, true, StringEncoding::Ascii) == "127.0.0.1");
@ Ascii
Encoding is ASCII.
#define SC_TEST_EXPECT(e)
Records a test expectation (eventually aborting or breaking o n failed test)
Definition: Testing.h:113
static Result resolveDNS(SpanStringView host, SpanString &ipAddress)
Resolve an host string to an ip address (blocking until DNS response arrives)

Member Function Documentation

◆ resolveDNS()

static Result SC::SocketDNS::resolveDNS ( SpanStringView  host,
SpanString ipAddress 
)
static

Resolve an host string to an ip address (blocking until DNS response arrives)

Parameters
[in]hostThe host string (example.com)
[out]ipAddressThe ip address of the given host string
Returns
Valid Result if ip address for the passed host has been successfully resolved

Example:

char buffer[256] = {0};
SpanString ipAddress = buffer;
SC_TEST_EXPECT(SocketDNS::resolveDNS("localhost", ipAddress));
SC_TEST_EXPECT(StringView(ipAddress.text, true, StringEncoding::Ascii) == "127.0.0.1");

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