Establishes a TCP connection to the given host and port using blocking DNS resolution via net::blocking::GetAddrInfo.
Definition in file connect_tcp_by_name.hpp.
Go to the source code of this file.
#include <cstdint>#include <string_view>#include <userver/engine/deadline.hpp>#include <userver/engine/io/socket.hpp>Functions | |
| engine::io::Socket | net::blocking::ConnectTcpByName (std::string_view host, std::uint16_t port, engine::Deadline deadline) |
| Establishes a TCP connection to the given host and port using blocking DNS resolution via net::blocking::GetAddrInfo. | |
| engine::io::Socket net::blocking::ConnectTcpByName | ( | std::string_view | host, |
| std::uint16_t | port, | ||
| engine::Deadline | deadline ) |
Establishes a TCP connection to the given host and port using blocking DNS resolution via net::blocking::GetAddrInfo.
Resolves the host name with getaddrinfo, then tries to connect to each resolved address in turn. The first successful connection is returned. TCP_NODELAY is set on the socket. Does not use clients::dns::Resolver; for async resolution use net::ConnectTcpByName.
| host | DNS name or IP address to connect to (e.g. "localhost", "127.0.0.1"). |
| port | TCP port number. |
| deadline | Maximum time allowed for the whole operation (resolution + connection). |
| std::runtime_error | if getaddrinfo fails (e.g. unknown host). |
| engine::io::IoException | if connection to all resolved addresses fails (e.g. connection refused, timeout). |