working commit
This commit is contained in:
+15
-1
@@ -4,11 +4,25 @@
|
||||
#include <format>
|
||||
|
||||
#include <udpclient.hpp>
|
||||
#include <resolver.hpp>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
UDPClient cli;
|
||||
std::string message("Hello");
|
||||
auto bindRes = cli.Bind("www.gnu.org", 1025);
|
||||
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user