| 6 | namespace NCoro { |
| 7 | |
| 8 | bool TryConnect(const TString& host, ui16 port, TDuration timeout) { |
| 9 | bool connected = false; |
| 10 | |
| 11 | auto f = [&connected, &host, port, timeout](TCont* c) { |
| 12 | TSocketHolder socket; |
| 13 | TNetworkAddress address(host, port); |
| 14 | connected = (0 == NCoro::ConnectT(c, socket, address, timeout)); |
| 15 | }; |
| 16 | |
| 17 | TContExecutor e(128 * 1024); |
| 18 | e.Create(f, "try_connect"); |
| 19 | e.Execute(); |
| 20 | return connected; |
| 21 | } |
| 22 | |
| 23 | bool WaitUntilConnectable(const TString& host, ui16 port, TDuration timeout) { |
| 24 | const TInstant deadline = timeout.ToDeadLine(); |
no test coverage detected