Sane C++ Libraries
C++ Platform Abstraction Libraries
Loading...
Searching...
No Matches
SC::SocketDNS Struct Reference

Synchronous DNS Resolution. More...

#include <Socket.h>

Static Public Member Functions

static Result resolveDNS (StringViewData host, Span< char > &ipAddress)
 Resolve an host string to an ip address (blocking until DNS response arrives)
 

Detailed Description

Synchronous DNS Resolution.

Example:

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

Member Function Documentation

◆ resolveDNS()

static Result SC::SocketDNS::resolveDNS ( StringViewData host,
Span< char > & ipAddress )
staticnodiscard

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

Parameters
[in]hostThe ASCII encoded host string (example.com)
[out]ipAddressHost ip address (ASCII encoded and null-terminated)
Returns
Valid Result if ip address for the passed host has been successfully resolved

Example:

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

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