Skip to content

Commit

Permalink
Update Main.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
xorz57 committed Dec 3, 2023
1 parent 2f751f9 commit c7ea4d1
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,13 @@ int main(int argc, char *argv[]) {
boost::asio::ip::tcp::resolver::iterator iterator = resolver.resolve(query);
auto socket = std::make_unique<boost::asio::ip::tcp::socket>(io_service);
socket->async_connect(iterator->endpoint(), [port, protocol, show](const boost::system::error_code &error) -> void {
if (!error) {
if (show != "closed") {
std::cout << "Port " << port << "/" << protocol << " is open." << std::endl;
}
} else {
if (show != "open") {
std::cout << "Port " << port << "/" << protocol << " is closed." << std::endl;
}
if ((error && show == "closed") || (!error && show == "open")) {
std::cout << "Port " << port << "/" << protocol << " is " << (error ? "closed" : "open") << "." << std::endl;
}
});
sockets.emplace(port, std::move(socket));
} catch (const boost::system::system_error &e) {
std::cerr << "Error: Failed to resolve host: " << host << "." << std::endl;
std::cerr << e.what() << std::endl;
return 1;
}
}
Expand Down

0 comments on commit c7ea4d1

Please sign in to comment.