-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
bf56f3e
commit a15eb1d
Showing
633 changed files
with
65 additions
and
170,019 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 |
---|---|---|
@@ -1,32 +1,30 @@ | ||
#include <iostream> | ||
|
||
#include "asio.hpp" | ||
|
||
int main(int argc, char** argv) { | ||
|
||
int main(int argc, char ** argv) { | ||
using namespace asio; | ||
io_context ctx; | ||
ip::tcp::resolver resolver(ctx); | ||
ip::tcp::resolver::results_type results = resolver.resolve("www.boost.org", "https"); | ||
|
||
using namespace asio; | ||
io_context ctx; | ||
ip::tcp::resolver resolver(ctx); | ||
ip::tcp::resolver::query query("www.boost.org", "https"); | ||
// End points | ||
for (const auto& endpoint : results) { | ||
std::cout << endpoint.endpoint() << std::endl; | ||
} | ||
|
||
// End points | ||
{ | ||
ip::tcp::resolver::iterator iter = resolver.resolve(query); | ||
ip::tcp::resolver::iterator end; // End marker. | ||
|
||
while (iter != end) { | ||
ip::tcp::endpoint endpoint = *iter++; | ||
std::cout << endpoint << std::endl; | ||
} | ||
ip::tcp::socket sokt(ctx); | ||
async_connect(sokt, results, [](const error_code& er, const ip::tcp::endpoint& endpoint) { | ||
if (!er) { | ||
std::cout << "Connected to: " << endpoint << std::endl; | ||
} else { | ||
std::cout << "async_connect error: " << er.message() << std::endl; | ||
} | ||
}); | ||
|
||
ip::tcp::socket sokt(ctx); | ||
async_connect(sokt, resolver.resolve(query), [](const error_code& er, const ip::tcp::endpoint& endpoint) { | ||
if (!er) { | ||
// Run the io_context to handle the asynchronous operations | ||
ctx.run(); | ||
|
||
} else { | ||
std::cout << "async_connect error:" << er.message() << std::endl; | ||
} | ||
}); | ||
return 0; | ||
} | ||
return 0; | ||
} |
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 |
---|---|---|
@@ -1,13 +1,45 @@ | ||
add_library(asio INTERFACE) | ||
target_include_directories(asio | ||
INTERFACE | ||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>" | ||
) | ||
|
||
if (WIN32) | ||
target_compile_definitions(asio INTERFACE -DASIO_HAS_STD_THREAD -DASIO_STANDALONE -D_WIN32_WINNT=0x0600) | ||
else(WIN32) | ||
target_compile_definitions(asio INTERFACE -DASIO_HAS_STD_THREAD -DASIO_STANDALONE) | ||
target_compile_options(asio INTERFACE -Wno-shadow -Wno-implicit-fallthrough) | ||
endif() | ||
find_package(Threads REQUIRED) | ||
CPMAddPackage("gh:chriskohlhoff/asio#[email protected]") | ||
|
||
# ASIO doesn't use CMake, we have to configure it manually. Extra notes for using on Windows: | ||
# | ||
# 1) If _WIN32_WINNT is not set, ASIO assumes _WIN32_WINNT=0x0501, i.e. Windows XP target, which is | ||
# definitely not the platform which most users target. | ||
# | ||
# 2) WIN32_LEAN_AND_MEAN is defined to make Winsock2 work. | ||
if(asio_ADDED) | ||
add_library(asio INTERFACE) | ||
target_include_directories(asio SYSTEM INTERFACE ${asio_SOURCE_DIR}/asio/include) | ||
target_compile_definitions(asio INTERFACE ASIO_STANDALONE ASIO_NO_DEPRECATED) | ||
target_link_libraries(asio INTERFACE Threads::Threads) | ||
|
||
if(WIN32) | ||
# macro see @ https://stackoverflow.com/a/40217291/1746503 | ||
macro(get_win32_winnt version) | ||
if(CMAKE_SYSTEM_VERSION) | ||
set(ver ${CMAKE_SYSTEM_VERSION}) | ||
string(REGEX MATCH "^([0-9]+).([0-9])" ver ${ver}) | ||
string(REGEX MATCH "^([0-9]+)" verMajor ${ver}) | ||
# Check for Windows 10, b/c we'll need to convert to hex 'A'. | ||
if("${verMajor}" MATCHES "10") | ||
set(verMajor "A") | ||
string(REGEX REPLACE "^([0-9]+)" ${verMajor} ver ${ver}) | ||
endif("${verMajor}" MATCHES "10") | ||
# Remove all remaining '.' characters. | ||
string(REPLACE "." "" ver ${ver}) | ||
# Prepend each digit with a zero. | ||
string(REGEX REPLACE "([0-9A-Z])" "0\\1" ver ${ver}) | ||
set(${version} "0x${ver}") | ||
endif() | ||
endmacro() | ||
|
||
if(NOT DEFINED _WIN32_WINNT) | ||
get_win32_winnt(ver) | ||
set(_WIN32_WINNT ${ver}) | ||
endif() | ||
|
||
message(STATUS "Set _WIN32_WINNET=${_WIN32_WINNT}") | ||
|
||
target_compile_definitions(asio INTERFACE _WIN32_WINNT=${_WIN32_WINNT} WIN32_LEAN_AND_MEAN) | ||
endif() | ||
endif() |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.