mirror of
https://github.com/boostorg/redis.git
synced 2026-01-26 19:02:08 +00:00
27 lines
974 B
C++
27 lines
974 B
C++
/* Copyright (c) 2019 - 2021 Marcelo Zimbres Silva (mzimbres at gmail dot com)
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#include <aedis/net.hpp>
|
|
|
|
using tcp_socket = aedis::net::use_awaitable_t<>::as_default_on_t<aedis::net::ip::tcp::socket>;
|
|
using tcp_resolver = aedis::net::use_awaitable_t<>::as_default_on_t<aedis::net::ip::tcp::resolver>;
|
|
using timer = aedis::net::use_awaitable_t<>::as_default_on_t<aedis::net::steady_timer>;
|
|
|
|
aedis::net::awaitable<tcp_socket>
|
|
connect(
|
|
std::string host = "127.0.0.1",
|
|
std::string port = "6379")
|
|
{
|
|
auto ex = co_await aedis::net::this_coro::executor;
|
|
tcp_resolver resolver{ex};
|
|
auto const res = co_await resolver.async_resolve(host, port);
|
|
tcp_socket socket{ex};
|
|
co_await aedis::net::async_connect(socket, res);
|
|
co_return std::move(socket);
|
|
}
|
|
|