working commit

This commit is contained in:
Олег Бородин
2026-05-05 11:37:10 +02:00
parent bd4df1e3da
commit eda9b8986b
62 changed files with 7546 additions and 476 deletions
+36
View File
@@ -0,0 +1,36 @@
#include <expected>
#include <iostream>
#include <format>
#include <udpclient.hpp>
#include <resolver.hpp>
int main(int argc, char** argv) {
UDPClient cli;
std::string message("Hello");
const std::string hostname("www.gnu.org");
Resolver resolver;
auto resolveRes = resolver.Resolve(hostname);
if (!resolveRes) {
auto msg = std::format("Cannot resolve hostname {}: {}", hostname, resolveRes.error());
std::cerr << std::format("Error: {}", msg) << std::endl;
return 1;
}
auto raddr = resolveRes.value();
auto address = raddr.GetAddress();
auto bindRes = cli.Bind(address, 1025);
if (!bindRes) {
std::cerr << std::format("Error: {}", bindRes.error()) << std::endl;
return 1;
}
auto sendRes = cli.Send(message);
if (!sendRes) {
std::cerr << std::format("Error: {}", sendRes.error()) << std::endl;
return 1;
}
return 0;
}