namespace mrpt::comms::net

A set of useful routines for networking.

(in #include <mrpt/comms/net_utils.h>)

namespace net {

// enums

enum http_errorcode;

// structs

struct HttpRequestOptions;
struct HttpRequestOutput;

// global functions

http_errorcode http_get(
    const string& url,
    std::vector<uint8_t>& out_content,
    const HttpRequestOptions& options = HttpRequestOptions(),
    mrpt::optional_ref<HttpRequestOutput> output = std::nullopt
    );

http_errorcode http_get(
    const string& url,
    string& out_content,
    const HttpRequestOptions& options = HttpRequestOptions(),
    mrpt::optional_ref<HttpRequestOutput> output = std::nullopt
    );

http_errorcode http_request(
    const string& http_method,
    const string& http_send_content,
    const string& url,
    std::vector<uint8_t>& out_content,
    const HttpRequestOptions& options = HttpRequestOptions(),
    mrpt::optional_ref<HttpRequestOutput> output = std::nullopt
    );

bool DNS_resolve_async(
    const std::string& server_name,
    std::string& out_ip,
    const unsigned int timeout_ms = 3000
    );

std::string getLastSocketErrorStr();

bool Ping(
    const std::string& address,
    const int max_attempts,
    std::string* output_str = nullptr
    );

} // namespace net