-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
frodez
committed
Oct 25, 2021
1 parent
0f685b1
commit 9962a83
Showing
4 changed files
with
44 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include <iostream> | ||
|
||
#include "spinet.h" | ||
|
||
int main(int argc, char* argv[]) { | ||
if (argc != 3) { | ||
std::cout << "Usage: PROGRAM_NAME ${address} ${port}" << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
char* ptr = nullptr; | ||
long port = strtol(argv[2], &ptr, 10); | ||
if (*ptr != 0) { | ||
std::cout << "port is an invalid number." << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
if (port < 0 || port > 65535) { | ||
std::cout << "port should be between 0 and 65535." << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
auto res = spinet::Address::resolve(argv[1], port); | ||
if (res.index() == 1) { | ||
std::cout << std::get<1>(res) << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
auto addresses = std::get<0>(res); | ||
for (auto& address : addresses) { | ||
std::cout << address.to_string() << std::endl; | ||
} | ||
return EXIT_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters